Package civitas.celestis.util.tuple
Class Object1<E>
java.lang.Object
civitas.celestis.util.tuple.Object1<E>
- Type Parameters:
E- The type of element to contain
- All Implemented Interfaces:
BaseTuple<E>,Tuple<E>,Serializable,Iterable<E>
A tuple with one element.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionE[]array()Returns an array containing the elements of this tuple in their proper order.booleanReturns whether this tuple contains the provided objectobj.booleancontainsAll(Iterable<?> i) Returns whether this tuple contains multiple objects.booleanChecks for equality between this tuple and the provided objectobj.voidforEach(BiConsumer<? super Integer, ? super E> a) Executes the provided actionaonce for each element of this tuple.voidExecutes the provided actionaonce for each element of this tuple.get()Returns the element of this tuple.get(int i) Returns theith element of this tuple.inthashCode()Returns the hash code of this instance.iterator()Returns an iterator over every element of this tuple.list()Returns an unmodifiable list containing the elements of this tuple in their proper order.<F> Tuple<F>Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.mapToDouble(ToDoubleFunction<? super E> f) Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.mapToFloat(ToFloatFunction<? super E> f) Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.mapToInt(ToIntFunction<? super E> f) Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.mapToLong(ToLongFunction<? super E> f) Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.<F,G> Tuple<G> merge(Tuple<F> t, BiFunction<? super E, ? super F, ? extends G> f) Between this tuple and the provided tuplet, this applies the merger functionfto each corresponding pair of elements, then returns a new tuple containing the return values of the merger functionf.intsize()Returns the size of this tuple.stream()Returns a stream whose source is the elements of this tuple.toString()Serializes this tuple into a string.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
spliterator
-
Field Details
-
element
The element of this tuple.
-
-
Constructor Details
-
Object1
Creates a new tuple.- Parameters:
element- The element of this tuple
-
Object1
Creates a new tuple.- Parameters:
elements- The singular array of this tuple's element- Throws:
IllegalArgumentException- When the provided array's length is not1
-
Object1
Creates a new tuple.- Parameters:
t- The tuple of which to copy elements from- Throws:
IllegalArgumentException- When the provided tuplet's size is not1
-
-
Method Details
-
size
public int size()Returns the size of this tuple. (the number of components it has) -
contains
Returns whether this tuple contains the provided objectobj. -
containsAll
Returns whether this tuple contains multiple objects.- Specified by:
containsAllin interfaceTuple<E>- Parameters:
i- The iterable object of which to check for containment- Returns:
trueif this tuple contains every element of the iterable object
-
get
Returns theith element of this tuple.- Specified by:
getin interfaceTuple<E>- Parameters:
i- The index of the element to get- Returns:
- The
ith element of this tuple - Throws:
IndexOutOfBoundsException- When the indexiis out of bounds
-
get
Returns the element of this tuple.- Returns:
- The element of this tuple
-
map
Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf. -
mapToDouble
Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.- Specified by:
mapToDoublein interfaceTuple<E>- Parameters:
f- The function of which to apply to each element of this tuple- Returns:
- The resulting
doubletuple
-
mapToFloat
Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf.- Specified by:
mapToFloatin interfaceTuple<E>- Parameters:
f- The function of which to apply to each element of this tuple- Returns:
- The resulting
doubletuple
-
mapToLong
Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf. -
mapToInt
Applies the provided mapper functionfto each element of this tuple, then returns a new tuple containing the return values of the functionf. -
merge
@Nonnull public <F,G> Tuple<G> merge(@Nonnull Tuple<F> t, @Nonnull BiFunction<? super E, ? super F, throws IllegalArgumentException? extends G> f) Between this tuple and the provided tuplet, this applies the merger functionfto each corresponding pair of elements, then returns a new tuple containing the return values of the merger functionf. In other words, this merges the two tuples into a new tuple using the provided merger functionf.- Specified by:
mergein interfaceTuple<E>- Type Parameters:
F- The type of element to merge this tuple withG- The type of element to merge the two tuples to- Parameters:
t- The tuple of which to merge this tuple withf- The merger function to handle the merging of the two tuples- Returns:
- The resulting tuple
- Throws:
IllegalArgumentException- When the provided tuplet's size is different from that of this tuple's size
-
iterator
Returns an iterator over every element of this tuple. -
forEach
Executes the provided actionaonce for each element of this tuple. A reference to the element is provided as the first parameter of the action. -
forEach
Executes the provided actionaonce for each element of this tuple. The index of the element is provided as the first parameter of the action, and a reference to the element is provided as the second parameter of the action. -
array
Returns an array containing the elements of this tuple in their proper order. -
stream
Returns a stream whose source is the elements of this tuple. -
list
Returns an unmodifiable list containing the elements of this tuple in their proper order. -
equals
Checks for equality between this tuple and the provided objectobj. -
toString
Serializes this tuple into a string. -
hashCode
public int hashCode()Returns the hash code of this instance.
-