@@ -41,6 +41,8 @@ public class EqualityTransformingCollectionBuilder<E> {
41
41
private BiPredicate <? super E , ? super E > equals ;
42
42
private ToIntFunction <? super E > hash ;
43
43
44
+ // #begin CONSTRUCTION
45
+
44
46
private EqualityTransformingCollectionBuilder (Class <? super E > outerKeyTypeToken ) {
45
47
this .outerKeyTypeToken = outerKeyTypeToken ;
46
48
// note that the methods from 'Objects' already implement the contract for null-safety
@@ -49,45 +51,43 @@ private EqualityTransformingCollectionBuilder(Class<? super E> outerKeyTypeToken
49
51
this .hash = Objects ::hashCode ;
50
52
}
51
53
52
- // #begin SET PROPERTIES
53
-
54
54
/**
55
- * Returns a new builder.
55
+ * Returns a new builder for the specified element type .
56
56
* <p>
57
- * This method can be called if no type token for the elements can be provided (if it can be, call the preferable
58
- * {@link #forKeyType(Class)} instead). A call might look as follows (for a generic type {@code T}):
59
- *
60
- * <pre>
61
- * EqualityTransformingBuilder.<T> forUnspecifiedKeyType();
62
- * </pre>
57
+ * If a type token for the elements can not be provided, call {@link #forTypeUnknown()} instead.
63
58
*
64
59
* @param <E>
65
- * the type of elements contained in the set created by the builder
60
+ * the type of elements contained in the created set
61
+ * @param keyTypeToken
62
+ * a type token for the elements contained in the created set
66
63
* @return a new builder
67
64
*/
68
- public static <E > EqualityTransformingCollectionBuilder <E > forUnspecifiedKeyType () {
69
- return new EqualityTransformingCollectionBuilder <>(Object .class );
65
+ public static <E > EqualityTransformingCollectionBuilder <E > forType (Class <? super E > keyTypeToken ) {
66
+ Objects .requireNonNull (keyTypeToken , "The argument 'keyTypeToken' must not be null." );
67
+ return new EqualityTransformingCollectionBuilder <>(keyTypeToken );
70
68
}
71
69
72
70
/**
73
- * Returns a new builder to create equality transforming sets for elements of the specified type.
71
+ * Returns a new builder for an unknown key type.
74
72
* <p>
75
- * If a type token for the keys can not be provided, call {@link #forUnspecifiedKeyType()} instead.
73
+ * This is equivalent to calling {@link #forType(Class) forKeyType(Object.class)}. To obtain a builder for
74
+ * {@code <E>} you will have to call {@code EqualityTransformingCollectionBuilder.<E> forTypeUnknown()}.
76
75
*
77
76
* @param <E>
78
77
* the type of elements contained in the set created by the builder
79
- * @param keyTypeToken
80
- * a type token for the elements contained in the set created by the builder
81
78
* @return a new builder
82
79
*/
83
- public static <E > EqualityTransformingCollectionBuilder <E > forKeyType (Class <? super E > keyTypeToken ) {
84
- Objects .requireNonNull (keyTypeToken , "The argument 'keyTypeToken' must not be null." );
85
- return new EqualityTransformingCollectionBuilder <>(keyTypeToken );
80
+ public static <E > EqualityTransformingCollectionBuilder <E > forTypeUnknown () {
81
+ return new EqualityTransformingCollectionBuilder <>(Object .class );
86
82
}
87
83
84
+ // #end CONSTRUCTION
85
+
86
+ // #begin SET PROPERTIES
87
+
88
88
/**
89
89
* @param equals
90
- * a function determining equality of keys ; might be called with null keys
90
+ * a function determining equality of elements ; might be called with null elements
91
91
* @return this builder
92
92
*/
93
93
public EqualityTransformingCollectionBuilder <E > withEqualsHandlingNull (BiPredicate <? super E , ? super E > equals ) {
@@ -98,7 +98,7 @@ public EqualityTransformingCollectionBuilder<E> withEqualsHandlingNull(BiPredica
98
98
99
99
/**
100
100
* @param equals
101
- * a function determining equality of keys ; will not be called with null keys
101
+ * a function determining equality of elements ; will not be called with null elements
102
102
* @return this builder
103
103
*/
104
104
public EqualityTransformingCollectionBuilder <E > withEquals (BiPredicate <? super E , ? super E > equals ) {
@@ -119,7 +119,7 @@ public EqualityTransformingCollectionBuilder<E> withEquals(BiPredicate<? super E
119
119
120
120
/**
121
121
* @param hash
122
- * a function computing the hash code of a key ; might be called with null keys
122
+ * a function computing the hash code of an element ; might be called with null elements
123
123
* @return this builder
124
124
*/
125
125
public EqualityTransformingCollectionBuilder <E > withHashHandlingNull (ToIntFunction <? super E > hash ) {
@@ -130,7 +130,7 @@ public EqualityTransformingCollectionBuilder<E> withHashHandlingNull(ToIntFuncti
130
130
131
131
/**
132
132
* @param hash
133
- * a function computing the hash code of a key ; will not be called with null keys
133
+ * a function computing the hash code of an element ; will not be called with null elements
134
134
* @return this builder
135
135
*/
136
136
public EqualityTransformingCollectionBuilder <E > withHash (ToIntFunction <? super E > hash ) {
@@ -162,7 +162,7 @@ public EqualityTransformingSet<E> buildSet() {
162
162
* an empty set which is not otherwise referenced
163
163
* @return a new instance of {@link EqualityTransformingSet}
164
164
*/
165
- public EqualityTransformingSet <E > buildSetDecorating (Set <Object > emptySet ) {
165
+ public EqualityTransformingSet <E > buildSet (Set <Object > emptySet ) {
166
166
return new EqualityTransformingSet <>(emptySet , outerKeyTypeToken , equals , hash );
167
167
}
168
168
@@ -186,7 +186,7 @@ public <V> EqualityTransformingMap<E, V> buildMap() {
186
186
* an empty map which is not otherwise referenced
187
187
* @return a new instance of {@link EqualityTransformingMap}
188
188
*/
189
- public <V > EqualityTransformingMap <E , V > buildMapDecorating (Map <Object , Object > emptyMap ) {
189
+ public <V > EqualityTransformingMap <E , V > buildMap (Map <Object , Object > emptyMap ) {
190
190
return new EqualityTransformingMap <>(emptyMap , outerKeyTypeToken , equals , hash );
191
191
}
192
192
0 commit comments