Skip to content

Method: equalsTemplate(Token)

1: package de.fhdw.wtf.common.token;
2:
3: /**
4: * This token contains at least one whitespace.
5: */
6: public class WhitespaceToken extends MultiCharToken {
7:         
8:         /**
9:          * generated.
10:          */
11:         private static final long serialVersionUID = 7922055796052935145L;
12:         
13:         /**
14:          * Protected Constructor for WhitespaceToken. Use create(...)-Factory instead!
15:          *
16:          * @param whitespace
17:          * initial whitespace string
18:          * @param position
19:          * start position of this whitespace in the original input
20:          */
21:         protected WhitespaceToken(final String whitespace, final Position position) {
22:                 super(whitespace, position);
23:         }
24:         
25:         /**
26:          * Factory for a {@link WhitespaceToken}.
27:          *
28:          * @param whitespace
29:          * initial whitespace string
30:          * @param position
31:          * start position of this comment in the original input
32:          * @return a new instance of this token
33:          */
34:         public static WhitespaceToken create(final String whitespace, final Position position) {
35:                 return new WhitespaceToken(whitespace, position);
36:         }
37:         
38:         @Override
39:         public boolean isWhitespaceToken() {
40:                 return true;
41:         }
42:         
43:         @Override
44:         protected boolean equalsTemplate(final Token t) {
45:•                if (t instanceof WhitespaceToken) {
46:                         final WhitespaceToken ct = (WhitespaceToken) t;
47:                         return this.getWhitespace().equals(ct.getWhitespace());
48:                 }
49:                 return false;
50:         }
51:         
52:         /**
53:          * Whitespace as string representation.
54:          *
55:          * @return whitespace represented by this token
56:          */
57:         public String getWhitespace() {
58:                 return this.getTokenString();
59:         }
60:         
61:         @Override
62:         protected int hashCodeTemplate() {
63:                 return this.getWhitespace().hashCode();
64:         }
65:         
66: }