Skip to content

Method: stringRepresentation()

1: package de.fhdw.wtf.common.token.symbols;
2:
3: import de.fhdw.wtf.common.token.Position;
4: import de.fhdw.wtf.common.token.Token;
5:
6: /**
7: * Represents the plus symbol '+' as a token.
8: */
9: public final class PlusSymbolToken extends SymbolToken {
10:         
11:         /**
12:          * generated.
13:          */
14:         private static final long serialVersionUID = 4218535422046007061L;
15:         
16:         /**
17:          * Defines constant for hashCodeTemplate().
18:          */
19:         private static final int HASHCODE_TEMPLATE_CONSTANT = 98242232;
20:         
21:         /**
22:          * Private constructor for {@link PlusSymbolToken}. Use create(...)-Factory instead!
23:          *
24:          * @param position
25:          * represents the start position of the symbol '+' in the original input.
26:          */
27:         private PlusSymbolToken(final Position position) {
28:                 super(position, SymbolConstants.PLUS);
29:         }
30:         
31:         /**
32:          * Factory method for {@link PlusSymbolToken}.
33:          *
34:          * @param position
35:          * represents the start position of this {@link SymbolToken} in the original input.
36:          * @return a new instance of this {@link SymbolToken}.
37:          */
38:         public static PlusSymbolToken create(final Position position) {
39:                 return new PlusSymbolToken(position);
40:         }
41:         
42:         @Override
43:         public boolean isPlusSymbolToken() {
44:                 return true;
45:         }
46:         
47:         @Override
48:         protected boolean equalsTemplate(final Token t) {
49:                 return t.isPlusSymbolToken();
50:         }
51:         
52:         @Override
53:         public String stringRepresentation() {
54:                 return SymbolConstants.PLUS;
55:         }
56:         
57:         @Override
58:         protected int hashCodeTemplate() {
59:                 return HASHCODE_TEMPLATE_CONSTANT;
60:         }
61: }