01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.types.enterprisemodel;
16:
17: /** Datatype representing cardinality of the selector */
18: public final class SelectorCardinality {
19: /** Constant describing the empty attribute stereotype */
20: public final static SelectorCardinality EMPTY = new SelectorCardinality(
21: "");
22: /** Constant describing the 'singular' cardinality where selector can only return at most one object */
23: public final static SelectorCardinality ZERO_OR_ONE = new SelectorCardinality(
24: "ZERO_OR_ONE");
25: /** Constant describing the 'plural' cardinality where selector can return any number of objects */
26: public final static SelectorCardinality ZERO_TO_MANY = new SelectorCardinality(
27: "ZERO_TO_MANY");
28:
29: /* SelectorCardinality name storage */
30: protected String mValue;
31:
32: /** Creates an instance of the datatype carrying an empty value */
33: public static SelectorCardinality createEmpty() {
34: return EMPTY;
35: }
36:
37: /* Private constructor. Restricts construction from outside */
38: private SelectorCardinality(String pValue) {
39: mValue = pValue;
40: }
41:
42: /** Indicates whether some other object is "equal to" this one
43: * @return true if this object is the same as the obj argument; false otherwise. */
44: public boolean equals(Object pOtherObject) {
45: if (pOtherObject == null)
46: return false;
47: if ((pOtherObject instanceof SelectorCardinality) == false)
48: return false;
49: return ((SelectorCardinality) pOtherObject).mValue
50: .equals(mValue);
51: }
52:
53: /** Returns true if this datatype contains an empty value */
54: public boolean isEmpty() {
55: return this == EMPTY;
56: }
57:
58: /** Returns true if this datatype contains plural cardinality */
59: public boolean isPlural() {
60: return this == ZERO_TO_MANY;
61: }
62:
63: /** Returns true if this datatype contains singular cardinality */
64: public boolean isSingular() {
65: return this == ZERO_OR_ONE;
66: }
67:
68: /** Returns human readable representation of the value */
69: public String toString() {
70: return mValue;
71: }
72: }
|