Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 8, 2024
1 parent 9a9f834 commit 094bd78
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ private static <T> T[] newArray(final T key1, final T key2, final T key3, final
/**
* Constructor taking two keys.
* <p>
* The keys should be immutable
* The keys should be immutable.
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
*
* @param key1 the first key
* @param key2 the second key
Expand All @@ -137,6 +138,7 @@ public MultiKey(final K key1, final K key2) {
* <p>
* The keys should be immutable
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
*
* @param key1 the first key
* @param key2 the second key
Expand All @@ -149,8 +151,9 @@ public MultiKey(final K key1, final K key2, final K key3) {
/**
* Constructor taking four keys.
* <p>
* The keys should be immutable
* The keys should be immutable.
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
*
* @param key1 the first key
* @param key2 the second key
Expand All @@ -164,8 +167,9 @@ public MultiKey(final K key1, final K key2, final K key3, final K key4) {
/**
* Constructor taking five keys.
* <p>
* The keys should be immutable
* The keys should be immutable.
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
*
* @param key1 the first key
* @param key2 the second key
Expand All @@ -180,10 +184,12 @@ public MultiKey(final K key1, final K key2, final K key3, final K key4, final K
/**
* Constructor taking an array of keys which is cloned.
* <p>
* The keys should be immutable
* The keys should be immutable.
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
* <p>
* This is equivalent to {@code new MultiKey(keys, true)}.
* </p>
*
* @param keys the array of keys, not null
* @throws NullPointerException if the key array is null
Expand All @@ -196,20 +202,23 @@ public MultiKey(final K[] keys) {
* Constructor taking an array of keys, optionally choosing whether to clone.
* <p>
* <strong>If the array is not cloned, then it must not be modified.</strong>
* </p>
* <p>
* This method is public for performance reasons only, to avoid a clone.
* The hash code is calculated once here in this method.
* Therefore, changing the array passed in would not change the hash code but
* would change the equals method, which is a bug.
* </p>
* <p>
* This is the only fully safe usage of this constructor, as the object array
* is never made available in a variable:
* <pre>
* new MultiKey(new Object[] {...}, false);
* </pre>
* <p>
* The keys should be immutable
* The keys should be immutable.
* If they are not then they must not be changed after adding to the MultiKey.
* </p>
*
* @param keys the array of keys, not null
* @param makeClone true to clone the array, false to assign it
Expand Down Expand Up @@ -241,6 +250,7 @@ private void calculateHashCode(final Object[] keys) {
* <p>
* To be equal, the other object must be a {@code MultiKey} with the
* same number of keys which are also equal.
* </p>
*
* @param other the other object to compare to
* @return true if equal
Expand All @@ -262,6 +272,7 @@ public boolean equals(final Object other) {
* <p>
* The key should be immutable.
* If it is not then it must not be changed.
* </p>
*
* @param index the index to retrieve
* @return the key at the index
Expand All @@ -277,6 +288,7 @@ public K getKey(final int index) {
* <p>
* The keys should be immutable
* If they are not then they must not be changed.
* </p>
*
* @return the individual keys
*/
Expand All @@ -291,6 +303,7 @@ public K[] getKeys() {
* change their hash codes once created (note that this is the same
* constraint that would be used if the individual keys elements were
* themselves {@link java.util.Map Map} keys).
* </p>
*
* @return the hash code
*/
Expand Down

0 comments on commit 094bd78

Please sign in to comment.