Skip to content

Method: compareTo(VariableTypeWrapper)

1: package gui.wrapperobjects;
2:
3: import model.type.NamedVariableType;
4:
5: /**
6: * This class wraps a VariableAssignment.
7: *
8: * @author Phil
9: *
10: */
11: public class VariableTypeWrapper implements Comparable<VariableTypeWrapper> {
12:         /**
13:          * The wrapped Type.
14:          */
15:         private final NamedVariableType wrappedType;
16:
17:         /**
18:          * Constructor, just sets fields. No side-effects.
19:          *
20:          * @param toWrap
21:          * The assignment to wrap.
22:          */
23:         public VariableTypeWrapper(final NamedVariableType toWrap) {
24:                 this.wrappedType = toWrap;
25:         }
26:
27:         /**
28:          * @return the wrappedAssignment
29:          */
30:         public NamedVariableType getWrappedType() {
31:                 return this.wrappedType;
32:         }
33:
34:         @Override
35:         public int compareTo(final VariableTypeWrapper o) {
36:                 return this.wrappedType.getPosition().compareTo(o.getWrappedType().getPosition());
37:         }
38:
39:         @Override
40:         public boolean equals(final Object o) {
41:                 if (o instanceof VariableTypeWrapper) {
42:                         return this.getWrappedType().equals(((VariableTypeWrapper) o).getWrappedType());
43:                 }
44:                 return false;
45:         }
46:
47:         @Override
48:         public int hashCode() {
49:                 return this.getWrappedType().hashCode();
50:         }
51: }