package model;
using StringTools;

class Link {
	public var set : Set;
	public var role(default, set) : String;
	public var classRole(default, null) : String;
	public var min : String;
	public var max : String;
	public var isWeak : Bool; //=isComposition
	public var isAgregate : Bool;
	public var hasArrow : Bool;
	public var visibility : Int;

	@SuppressWarnings("checkstyle:ParameterNumber")
	public function new(set : Set, role : String, min : String, max : String, isWeak : Bool, isAgregate : Bool, hasArrow : Bool, visibility : Int) {
		this.set = set;
		this.role = role;
		this.min = min;
		this.max = max;
		this.isWeak = isWeak;
		this.isAgregate = isAgregate;
		this.hasArrow = hasArrow;
		this.visibility = visibility;
	}

	function set_role(role : String) : String {
		this.role = role;
		classRole = Obj.fixName(role);
		return this.role;
	}

	public function getMCDCards() : String {
		return min == "X" && max == "X" ? "" : min + "," + max;
	}

	public function getUMLCards() : String {
		var cards : String = "";
		if (min != "X" || max != "X") {
			if (min == max) {
				cards = min;
			} else if (min == "0" && max == "N") {
				cards = "*";
			} else {
				cards = min + ".." + max.replace("N", "*");
			}
		}
		return cards;
	}
}
