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 attribute stereotypes */
18: public final class TemplateSourceType {
19: /** Constant describing the Apache's Velocity engine template */
20: public final static TemplateSourceType VELOCITY = new TemplateSourceType(
21: "VELOCITY");
22: /** Constant describing the MetaBoss's own java template */
23: public final static TemplateSourceType JAVA = new TemplateSourceType(
24: "JAVA");
25: /** Constant describing the Jamon java template */
26: public final static TemplateSourceType JAMON = new TemplateSourceType(
27: "JAMON");
28:
29: /* Stereotype name storage */
30: protected String mValue;
31:
32: /** Creates an instance of the datatype carrying an empty value */
33: public static TemplateSourceType createFromString(String pValue) {
34: if (pValue == null)
35: throw new IllegalArgumentException(
36: "Null is not allowed here");
37: if (pValue.equals(VELOCITY.mValue))
38: return VELOCITY;
39: if (pValue.equals(JAVA.mValue))
40: return JAVA;
41: if (pValue.equals(JAMON.mValue))
42: return JAMON;
43: throw new IllegalArgumentException(
44: "Invalid string value - unable to create datatype instance from '"
45: + pValue + "'");
46: }
47:
48: /* Private constructor. Restricts construction from outside */
49: private TemplateSourceType(String pValue) {
50: mValue = pValue;
51: }
52:
53: /** Indicates whether some other object is "equal to" this one
54: * @return true if this object is the same as the obj argument; false otherwise. */
55: public boolean equals(Object pOtherObject) {
56: if (pOtherObject == null)
57: return false;
58: if ((pOtherObject instanceof TemplateSourceType) == false)
59: return false;
60: return ((TemplateSourceType) pOtherObject).mValue
61: .equals(mValue);
62: }
63:
64: /** Returns human readable representation of the value */
65: public String toString() {
66: return mValue;
67: }
68: }
|