@@ -41,6 +41,8 @@ public class EqualityTransformingCollectionBuilder<E> {
4141 private BiPredicate <? super E , ? super E > equals ;
4242 private ToIntFunction <? super E > hash ;
4343
44+ // #begin CONSTRUCTION
45+
4446 private EqualityTransformingCollectionBuilder (Class <? super E > outerKeyTypeToken ) {
4547 this .outerKeyTypeToken = outerKeyTypeToken ;
4648 // note that the methods from 'Objects' already implement the contract for null-safety
@@ -49,45 +51,43 @@ private EqualityTransformingCollectionBuilder(Class<? super E> outerKeyTypeToken
4951 this .hash = Objects ::hashCode ;
5052 }
5153
52- // #begin SET PROPERTIES
53-
5454 /**
55- * Returns a new builder.
55+ * Returns a new builder for the specified element type .
5656 * <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 #forKeyTypeUnknown()} instead.
6358 *
6459 * @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
6663 * @return a new builder
6764 */
68- public static <E > EqualityTransformingCollectionBuilder <E > forUnspecifiedKeyType () {
69- return new EqualityTransformingCollectionBuilder <>(Object .class );
65+ public static <E > EqualityTransformingCollectionBuilder <E > forKeyType (Class <? super E > keyTypeToken ) {
66+ Objects .requireNonNull (keyTypeToken , "The argument 'keyTypeToken' must not be null." );
67+ return new EqualityTransformingCollectionBuilder <>(keyTypeToken );
7068 }
7169
7270 /**
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.
7472 * <p>
75- * If a type token for the keys can not be provided, call {@link #forUnspecifiedKeyType()} instead.
73+ * This is equivalent to calling {@link #forKeyType(Class) forKeyType(Object.class)}. To obtain a builder for
74+ * {@code <E>} you will have to call {@code EqualityTransformingCollectionBuilder.<E> forKeyTypeUnknown()}.
7675 *
7776 * @param <E>
7877 * 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
8178 * @return a new builder
8279 */
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 > forKeyTypeUnknown () {
81+ return new EqualityTransformingCollectionBuilder <>(Object .class );
8682 }
8783
84+ // #end CONSTRUCTION
85+
86+ // #begin SET PROPERTIES
87+
8888 /**
8989 * @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
9191 * @return this builder
9292 */
9393 public EqualityTransformingCollectionBuilder <E > withEqualsHandlingNull (BiPredicate <? super E , ? super E > equals ) {
@@ -98,7 +98,7 @@ public EqualityTransformingCollectionBuilder<E> withEqualsHandlingNull(BiPredica
9898
9999 /**
100100 * @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
102102 * @return this builder
103103 */
104104 public EqualityTransformingCollectionBuilder <E > withEquals (BiPredicate <? super E , ? super E > equals ) {
@@ -119,7 +119,7 @@ public EqualityTransformingCollectionBuilder<E> withEquals(BiPredicate<? super E
119119
120120 /**
121121 * @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
123123 * @return this builder
124124 */
125125 public EqualityTransformingCollectionBuilder <E > withHashHandlingNull (ToIntFunction <? super E > hash ) {
@@ -130,7 +130,7 @@ public EqualityTransformingCollectionBuilder<E> withHashHandlingNull(ToIntFuncti
130130
131131 /**
132132 * @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
134134 * @return this builder
135135 */
136136 public EqualityTransformingCollectionBuilder <E > withHash (ToIntFunction <? super E > hash ) {
@@ -162,7 +162,7 @@ public EqualityTransformingSet<E> buildSet() {
162162 * an empty set which is not otherwise referenced
163163 * @return a new instance of {@link EqualityTransformingSet}
164164 */
165- public EqualityTransformingSet <E > buildSetDecorating (Set <Object > emptySet ) {
165+ public EqualityTransformingSet <E > buildSet (Set <Object > emptySet ) {
166166 return new EqualityTransformingSet <>(emptySet , outerKeyTypeToken , equals , hash );
167167 }
168168
@@ -186,7 +186,7 @@ public <V> EqualityTransformingMap<E, V> buildMap() {
186186 * an empty map which is not otherwise referenced
187187 * @return a new instance of {@link EqualityTransformingMap}
188188 */
189- public <V > EqualityTransformingMap <E , V > buildMapDecorating (Map <Object , Object > emptyMap ) {
189+ public <V > EqualityTransformingMap <E , V > buildMap (Map <Object , Object > emptyMap ) {
190190 return new EqualityTransformingMap <>(emptyMap , outerKeyTypeToken , equals , hash );
191191 }
192192
0 commit comments