Skip to content

Method: hashCode()

1: package symbols;
2:
3: import model.Position;
4: import scanner.ScannerConstants;
5:
6: /**
7: * This class represents the Regular Expression Symbol.
8: *
9: * @author HFW410
10: *
11: */
12: public class RegExpSymbol extends AbstractSymbol {
13:
14:         /**
15:          * This is the expression of the Symbol.
16:          */
17:         private final transient String expression;
18:
19:         /**
20:          * This constructor initialize the RegExpSymbol.
21:          *
22:          * @param ausdruck
23:          * of the Symbol.
24:          * @param position
25:          * of the expression in thedatastream
26:          */
27:         public RegExpSymbol(final String ausdruck, final Position position) {
28:                 super(position);
29:                 this.expression = ausdruck;
30:         }
31:
32:         /**
33:          *
34:          * @return the expression
35:          */
36:         public String getExpression() {
37:                 return this.expression;
38:         }
39:
40:         @Override
41:         public String toString() {
42:                 return ScannerConstants.REGEXP + this.expression + this.getPosition();
43:         }
44:
45:         @Override
46:         public boolean equals(final Object obj) {
47:                 return super.equals(obj) && obj instanceof RegExpSymbol
48:                                 && ((RegExpSymbol) obj).getExpression().equals(this.getExpression());
49:         }
50:
51:         @Override
52:         public int hashCode() {
53:                 return super.hashCode() + this.expression.hashCode();
54:         }
55: }