Skip to content

Method: DummyToken()

1: package de.fhdw.wtf.common.token;
2:
3: /**
4: * Virtual Token, used for Prototypes.
5: */
6: public final class DummyToken extends EndToken {
7:         
8:         /**
9:          * generated.
10:          */
11:         private static final long serialVersionUID = 5345040412518771533L;
12:         
13:         /**
14:          * Constant to define hashCode().
15:          */
16:         private static final int HASHCODE_CONSTANT = 3243242;
17:         
18:         /**
19:          * Static attribute for Singleton.
20:          */
21:         private static DummyToken dummyToken;
22:         
23:         /**
24:          * Constructor of {@link DummyToken}.
25:          */
26:         private DummyToken() {
27:                 super(getDummyPosition());
28:         }
29:         
30:         /**
31:          * Get the Singleton-Instance of {@link DummyToken}.
32:          *
33:          * @return DummyToken
34:          */
35:         public static synchronized DummyToken getInstance() {
36:                 if (dummyToken == null) {
37:                         dummyToken = new DummyToken();
38:                 }
39:                 return dummyToken;
40:         }
41:         
42:         /**
43:          * Get the Dummy-Position.
44:          *
45:          * @return Dummy-Position
46:          */
47:         public static Position getDummyPosition() {
48:                 return Position.create("", -1, -1, -1);
49:         }
50:         
51:         @Override
52:         public boolean equals(final Object o) {
53:                 return o instanceof DummyToken;
54:         }
55:         
56:         @Override
57:         public int hashCode() {
58:                 return HASHCODE_CONSTANT;
59:         }
60: }