Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/validation/typing/MultiplicityFacade.java')
-rw-r--r--plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/validation/typing/MultiplicityFacade.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/validation/typing/MultiplicityFacade.java b/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/validation/typing/MultiplicityFacade.java
new file mode 100644
index 00000000000..ec2e15d6af9
--- /dev/null
+++ b/plugins/uml/alf/org.eclipse.papyrus.uml.alf/src/org/eclipse/papyrus/uml/alf/validation/typing/MultiplicityFacade.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.validation.typing;
+
+public class MultiplicityFacade {
+ private int lowerBound = 0;
+ private int upperBound = 0;
+ private boolean nonUnique = false ;
+ private boolean ordered = false ;
+
+ public String getLabel() {
+ if (lowerBound == upperBound) {
+ if (lowerBound == 1)
+ return "" ;
+ if (lowerBound == -1)
+ return "[*]" ;
+ return "[" + lowerBound + "]" ;
+ }
+ else {
+ if (upperBound == -1) {
+ if (lowerBound == 0) {
+ return "[*]" ;
+ }
+ else {
+ return "[" + lowerBound + "..*]" ;
+ }
+ }
+ else {
+ return "[" + lowerBound + ".." + upperBound + "]";
+ }
+ }
+ }
+
+ public boolean isCompatibleWithMe(MultiplicityFacade multiplicity) {
+ //boolean lowerBoundCompatible = multiplicity.lowerBound >= this.lowerBound ;
+ boolean upperBoundCompatible = true ;
+
+ switch (this.upperBound) {
+ case -1:
+ break;
+
+ default:
+ if (multiplicity.upperBound == -1)
+ upperBoundCompatible = false ;
+// else
+// upperBoundCompatible = multiplicity.upperBound <= this.upperBound ;
+ break;
+ }
+
+ //return lowerBoundCompatible && upperBoundCompatible;
+ return upperBoundCompatible ;
+ }
+
+ public void setLowerBound(int lowerBound) {
+ this.lowerBound = lowerBound ;
+ }
+
+ public void setUpperBound(int lowerBound) {
+ this.upperBound = lowerBound ;
+ }
+
+ public int getLowerBound() {
+ return lowerBound;
+ }
+
+ public int getUpperBound() {
+ return upperBound;
+ }
+
+ public boolean isUnique() {
+ return !nonUnique ;
+ }
+
+ public boolean isOrdered() {
+ return ordered ;
+ }
+
+ public boolean isSequence() {
+ return ordered && nonUnique ;
+ }
+
+ public void setIsUnique(boolean isUnique) {
+ nonUnique = !isUnique ;
+ }
+
+ public void setIsOrdered(boolean isOrdered) {
+ ordered = isOrdered ;
+ }
+
+ public void setIsSequence(boolean isSequence) {
+ ordered = true ;
+ nonUnique = true ;
+ }
+}

Back to the top