Skip to content

Method: equalsTemplate(Token)

1: package de.fhdw.wtf.common.token.keywords;
2:
3: import de.fhdw.wtf.common.token.Position;
4: import de.fhdw.wtf.common.token.Token;
5:
6: /**
7: * Represents the "abstract"-modifier as a token in WTF.
8: */
9: public final class AbstractToken extends ClassModifierToken {
10:         
11:         /**
12:          * generated.
13:          */
14:         private static final long serialVersionUID = 1183547882479606069L;
15:         
16:         /**
17:          * Defines constant for hashCodeTemplate().
18:          */
19:         private static final int HASHCODE_TEMPLATE_CONSTANT = 849783;
20:         
21:         /**
22:          * Defines constant "abstract" for {@link AbstractToken}.
23:          */
24:         private static final String TEXTUAL_REPRESENTATION = "abstract";
25:         
26:         /**
27:          * Private constructor for {@link AbstractToken}. Use create(...)-Factory instead!
28:          *
29:          * @param position
30:          * represents the start position of the {@link ClassModifierToken} <abstract> in the original input.
31:          */
32:         private AbstractToken(final Position position) {
33:                 super(position);
34:         }
35:         
36:         /**
37:          * Factory method for {@link AbstractToken}.
38:          *
39:          * @param position
40:          * represents the start position of this {@link ClassModifierToken} in the original input.
41:          * @return a new instance of this {@link ClassModifierToken} token.
42:          */
43:         public static AbstractToken create(final Position position) {
44:                 return new AbstractToken(position);
45:         }
46:         
47:         @Override
48:         public boolean isAbstractModifierToken() {
49:                 return true;
50:         }
51:         
52:         @Override
53:         public boolean isOperationModifierToken() {
54:                 return true;
55:         }
56:         
57:         @Override
58:         public boolean isAbstractOperationToken() {
59:                 return true;
60:         }
61:         
62:         @Override
63:         protected boolean equalsTemplate(final Token t) {
64:                 return t.isAbstractModifierToken();
65:         }
66:         
67:         @Override
68:         public String stringRepresentation() {
69:                 return TEXTUAL_REPRESENTATION;
70:         }
71:         
72:         @Override
73:         public int getLength() {
74:                 return AbstractToken.TEXTUAL_REPRESENTATION.length();
75:         }
76:         
77:         @Override
78:         protected int hashCodeTemplate() {
79:                 return HASHCODE_TEMPLATE_CONSTANT;
80:         }
81: }