|
@@ -11,12 +11,14 @@ |
11 |
11 |
|
} |
12 |
12 |
|
|
13 |
13 |
|
@SuppressWarnings({"unchecked"}) |
14 |
|
- |
protected class Wrapper implements Comparable<Wrapper> |
|
14 |
+ |
protected static final class Wrapper<E, C extends Comparable<C>> implements Comparable<Wrapper<E, C>> |
15 |
15 |
|
{ |
|
16 |
+ |
private final NoEqualsHelper<E, C> mHelper; |
16 |
17 |
|
private final E mObjectWithProxyValue; |
17 |
18 |
|
|
18 |
|
- |
public Wrapper( E pObjectWithProxyValue ) |
|
19 |
+ |
public Wrapper( NoEqualsHelper<E, C> pHelper, E pObjectWithProxyValue ) |
19 |
20 |
|
{ |
|
21 |
+ |
mHelper = pHelper; |
20 |
22 |
|
mObjectWithProxyValue = pObjectWithProxyValue; |
21 |
23 |
|
} |
22 |
24 |
|
|
|
@@ -31,27 +33,35 @@ |
31 |
33 |
|
} |
32 |
34 |
|
|
33 |
35 |
|
@Override |
34 |
|
- |
public boolean equals( Object obj ) |
|
36 |
+ |
public boolean equals( Object them ) |
35 |
37 |
|
{ |
36 |
|
- |
return (obj instanceof Wrapper) && equals( (Wrapper) obj ); |
|
38 |
+ |
return (this == them) || ((them != null) && // |
|
39 |
+ |
this.getClass().equals( them.getClass() ) && // |
|
40 |
+ |
LLNotNullEquals( (Wrapper<E, C>) them )); |
37 |
41 |
|
} |
38 |
42 |
|
|
39 |
|
- |
public boolean equals( Wrapper them ) |
|
43 |
+ |
public boolean equals( Wrapper<E, C> them ) |
40 |
44 |
|
{ |
41 |
|
- |
return (them != null) && areEqual( mHelper.getProxyValue( this.mObjectWithProxyValue ), mHelper.getProxyValue( them.mObjectWithProxyValue ) ); |
|
45 |
+ |
return (this == them) || ((them != null) && // |
|
46 |
+ |
LLNotNullEquals( them )); |
|
47 |
+ |
} |
|
48 |
+ |
|
|
49 |
+ |
private boolean LLNotNullEquals( Wrapper<E, C> them ) |
|
50 |
+ |
{ |
|
51 |
+ |
return areEqual( this.getProxyValue(), them.getProxyValue() ); |
42 |
52 |
|
} |
43 |
53 |
|
|
44 |
54 |
|
@Override |
45 |
55 |
|
public int hashCode() |
46 |
56 |
|
{ |
47 |
|
- |
Comparable<?> zProxyValue = mHelper.getProxyValue( mObjectWithProxyValue ); |
|
57 |
+ |
Comparable<?> zProxyValue = getProxyValue(); |
48 |
58 |
|
return (zProxyValue == null) ? 0 : zProxyValue.hashCode(); |
49 |
59 |
|
} |
50 |
60 |
|
|
51 |
61 |
|
@Override |
52 |
|
- |
public int compareTo( Wrapper them ) |
|
62 |
+ |
public int compareTo( Wrapper<E, C> them ) |
53 |
63 |
|
{ |
54 |
|
- |
return compare( mHelper.getProxyValue( this.mObjectWithProxyValue ), mHelper.getProxyValue( them.mObjectWithProxyValue ) ); |
|
64 |
+ |
return compare( this.getProxyValue(), them.getProxyValue() ); |
55 |
65 |
|
} |
56 |
66 |
|
|
57 |
67 |
|
@Override |
|
@@ -81,17 +91,22 @@ |
81 |
91 |
|
} |
82 |
92 |
|
} |
83 |
93 |
|
|
84 |
|
- |
protected Wrapper wrap( E pObject ) |
|
94 |
+ |
protected Wrapper<E, C>[] array( int pSize ) |
85 |
95 |
|
{ |
86 |
|
- |
return new Wrapper( pObject ); |
|
96 |
+ |
return new Wrapper[pSize]; |
87 |
97 |
|
} |
88 |
98 |
|
|
89 |
|
- |
protected E unwrap( Wrapper pWrapper ) |
|
99 |
+ |
protected Wrapper<E, C> wrap( E pObject ) |
|
100 |
+ |
{ |
|
101 |
+ |
return new Wrapper<E, C>( mHelper, pObject ); |
|
102 |
+ |
} |
|
103 |
+ |
|
|
104 |
+ |
protected E unwrap( Wrapper<E, C> pWrapper ) |
90 |
105 |
|
{ |
91 |
106 |
|
return (pWrapper != null) ? pWrapper.mObjectWithProxyValue : null; |
92 |
107 |
|
} |
93 |
108 |
|
|
94 |
|
- |
protected Wrapper wrapNotNull( E pObject ) |
|
109 |
+ |
protected Wrapper<E, C> wrapNotNull( E pObject ) |
95 |
110 |
|
{ |
96 |
111 |
|
validateNotNull( pObject ); |
97 |
112 |
|
return wrap( pObject ); |
|
@@ -130,6 +145,4 @@ |
130 |
145 |
|
{ |
131 |
146 |
|
return (p1 == p2) || ((p1 != null) && p1.equals( p2 )); |
132 |
147 |
|
} |
133 |
|
- |
|
134 |
|
- |
protected static final Wrapper[] EMPTY_ARRAY = new Wrapper[0]; |
135 |
148 |
|
} |