package model;

class Method extends Field { //UML
	public var params: Array<Field>;

	public function new(name : String, type : String, visibility : Int = 0, isStatic : Bool = false) {
		super(name, type, visibility, isStatic);
		this.params = new Array();
	}

	override public function toUMLString() : String {
		var str : String = Field.getVisibilitySymbol(visibility) + " " + className + "(";
		str += Lambda.map(params, param -> param.className + ":" + param.classType).join(", ");
		str += ")";
		if (classType != "") {
			str += " : " + classType;
		}
		return str;
	}

	public function isGeneric() : Bool {
		return classType.indexOf("<T>") != -1 || classType == "T" ||
			Lambda.exists(params, p -> p.classType.indexOf("<T>") != -1 || p.classType == "T");
	}
}
