This commit is contained in:
Gary Gregory 2024-12-08 14:37:29 -05:00
parent 9a9f834fd1
commit 094bd78efd
1 changed files with 18 additions and 5 deletions

View File

@ -122,8 +122,9 @@ public class MultiKey<K> implements Serializable {
/** /**
* Constructor taking two keys. * Constructor taking two keys.
* <p> * <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. * If they are not then they must not be changed after adding to the MultiKey.
* </p>
* *
* @param key1 the first key * @param key1 the first key
* @param key2 the second key * @param key2 the second key
@ -137,6 +138,7 @@ public class MultiKey<K> implements Serializable {
* <p> * <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. * If they are not then they must not be changed after adding to the MultiKey.
* </p>
* *
* @param key1 the first key * @param key1 the first key
* @param key2 the second key * @param key2 the second key
@ -149,8 +151,9 @@ public class MultiKey<K> implements Serializable {
/** /**
* Constructor taking four keys. * Constructor taking four keys.
* <p> * <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. * If they are not then they must not be changed after adding to the MultiKey.
* </p>
* *
* @param key1 the first key * @param key1 the first key
* @param key2 the second key * @param key2 the second key
@ -164,8 +167,9 @@ public class MultiKey<K> implements Serializable {
/** /**
* Constructor taking five keys. * Constructor taking five keys.
* <p> * <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. * If they are not then they must not be changed after adding to the MultiKey.
* </p>
* *
* @param key1 the first key * @param key1 the first key
* @param key2 the second key * @param key2 the second key
@ -180,10 +184,12 @@ public class MultiKey<K> implements Serializable {
/** /**
* Constructor taking an array of keys which is cloned. * Constructor taking an array of keys which is cloned.
* <p> * <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. * If they are not then they must not be changed after adding to the MultiKey.
* </p>
* <p> * <p>
* This is equivalent to {@code new MultiKey(keys, true)}. * This is equivalent to {@code new MultiKey(keys, true)}.
* </p>
* *
* @param keys the array of keys, not null * @param keys the array of keys, not null
* @throws NullPointerException if the key array is null * @throws NullPointerException if the key array is null
@ -196,11 +202,13 @@ public class MultiKey<K> implements Serializable {
* Constructor taking an array of keys, optionally choosing whether to clone. * Constructor taking an array of keys, optionally choosing whether to clone.
* <p> * <p>
* <strong>If the array is not cloned, then it must not be modified.</strong> * <strong>If the array is not cloned, then it must not be modified.</strong>
* </p>
* <p> * <p>
* This method is public for performance reasons only, to avoid a clone. * This method is public for performance reasons only, to avoid a clone.
* The hash code is calculated once here in this method. * The hash code is calculated once here in this method.
* Therefore, changing the array passed in would not change the hash code but * Therefore, changing the array passed in would not change the hash code but
* would change the equals method, which is a bug. * would change the equals method, which is a bug.
* </p>
* <p> * <p>
* This is the only fully safe usage of this constructor, as the object array * This is the only fully safe usage of this constructor, as the object array
* is never made available in a variable: * is never made available in a variable:
@ -208,8 +216,9 @@ public class MultiKey<K> implements Serializable {
* new MultiKey(new Object[] {...}, false); * new MultiKey(new Object[] {...}, false);
* </pre> * </pre>
* <p> * <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. * 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 keys the array of keys, not null
* @param makeClone true to clone the array, false to assign it * @param makeClone true to clone the array, false to assign it
@ -241,6 +250,7 @@ public class MultiKey<K> implements Serializable {
* <p> * <p>
* To be equal, the other object must be a {@code MultiKey} with the * To be equal, the other object must be a {@code MultiKey} with the
* same number of keys which are also equal. * same number of keys which are also equal.
* </p>
* *
* @param other the other object to compare to * @param other the other object to compare to
* @return true if equal * @return true if equal
@ -262,6 +272,7 @@ public class MultiKey<K> implements Serializable {
* <p> * <p>
* The key should be immutable. * The key should be immutable.
* If it is not then it must not be changed. * If it is not then it must not be changed.
* </p>
* *
* @param index the index to retrieve * @param index the index to retrieve
* @return the key at the index * @return the key at the index
@ -277,6 +288,7 @@ public class MultiKey<K> implements Serializable {
* <p> * <p>
* The keys should be immutable * The keys should be immutable
* If they are not then they must not be changed. * If they are not then they must not be changed.
* </p>
* *
* @return the individual keys * @return the individual keys
*/ */
@ -291,6 +303,7 @@ public class MultiKey<K> implements Serializable {
* change their hash codes once created (note that this is the same * change their hash codes once created (note that this is the same
* constraint that would be used if the individual keys elements were * constraint that would be used if the individual keys elements were
* themselves {@link java.util.Map Map} keys). * themselves {@link java.util.Map Map} keys).
* </p>
* *
* @return the hash code * @return the hash code
*/ */