Documentatie Tuple
This commit is contained in:
@@ -19,24 +19,22 @@ import java.util.Objects;
|
|||||||
@Value
|
@Value
|
||||||
public class Tuple<T1, T2> {
|
public class Tuple<T1, T2> {
|
||||||
|
|
||||||
/**
|
|
||||||
* The variable referencing the first item of this Tuple.
|
|
||||||
*/
|
|
||||||
public final T1 item1;
|
public final T1 item1;
|
||||||
|
|
||||||
/**
|
|
||||||
* The variable referencing the second item of this Tuple.
|
|
||||||
*/
|
|
||||||
public final T2 item2;
|
public final T2 item2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this new Tuple as a Tuple with the given items.
|
|
||||||
*
|
|
||||||
* @param item1
|
* @param item1
|
||||||
* The first element for this tuple.
|
|
||||||
* @param item2
|
* @param item2
|
||||||
* The second element for this tuple.
|
*
|
||||||
|
* @post ...
|
||||||
|
* |this.item1 == item1
|
||||||
|
* @post ...
|
||||||
|
* |this.item2
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException ...
|
||||||
|
* |
|
||||||
*/
|
*/
|
||||||
public Tuple(T1 item1, T2 item2) throws IllegalArgumentException {
|
public Tuple(T1 item1, T2 item2) throws IllegalArgumentException {
|
||||||
|
|
||||||
@@ -45,14 +43,13 @@ public class Tuple<T1, T2> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param item1
|
* @param item1
|
||||||
* The value for the first element.
|
|
||||||
* @param item2
|
* @param item2
|
||||||
* The value for the second element.
|
* @param <T1>
|
||||||
* @return
|
* @param <T2>
|
||||||
* The Tuple created from item1 and item2.
|
*
|
||||||
* | result == new Tuple<>(item1, item2);
|
* @return ...
|
||||||
|
* |result == new Tuple<>(item1, item2)
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
public static <T1, T2> Tuple<T1, T2> create(T1 item1, T2 item2){
|
public static <T1, T2> Tuple<T1, T2> create(T1 item1, T2 item2){
|
||||||
@@ -60,15 +57,12 @@ public class Tuple<T1, T2> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new Tuple created from the elements of the array.
|
|
||||||
*
|
|
||||||
* @param arr
|
* @param arr
|
||||||
* The Array to create the tuple of.
|
*
|
||||||
* @return The Tuple created from the elements of the given array.
|
* @return ...
|
||||||
* |result == new Tuple<>(arr[0], arr[1])
|
* |result == new Tuple<>(arr[0], arr[1])
|
||||||
* @throws IllegalArgumentException
|
*
|
||||||
* The given array is null or the length of the given array
|
* @throws IllegalArgumentException ...
|
||||||
* is not 2.
|
|
||||||
* |arr == null || arr.length != 2
|
* |arr == null || arr.length != 2
|
||||||
*/
|
*/
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -79,17 +73,15 @@ public class Tuple<T1, T2> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the Tuple to the given object.
|
|
||||||
*
|
|
||||||
* @param o
|
* @param o
|
||||||
* The object to compare to.
|
*
|
||||||
* @return True if and only if the given object is this Tuple.
|
* @return ...
|
||||||
* | if (this == 0) then result == true
|
* |if (this == o)
|
||||||
* Otherwise, true if the given object is a Tuple and
|
* | result == true
|
||||||
* the items are the same as this Tuple.
|
* |if (!(o instanceof Tuple))
|
||||||
* | else result ==
|
* | result == false
|
||||||
* | Objects.equals(item1, tuple.item1) &&
|
* |Tuple<?, ?> tuple = (Tuple<?, ?> o
|
||||||
* | Objects.equals(item2, tuple.item2);
|
* |result == Objects.equals(item1, tuple.item1) && Objects.equals(item2, tuple.item2)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
@@ -101,9 +93,7 @@ public class Tuple<T1, T2> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a hash code of the items of the Tuple
|
* @return ...
|
||||||
*
|
|
||||||
* @return The hash code of item1 and item2
|
|
||||||
* |result == Objects.hash(item1, item2)
|
* |result == Objects.hash(item1, item2)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user