com.mmnaseri.utils.tuples.facade.HasEighth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tuples4j Show documentation
Show all versions of tuples4j Show documentation
Tiny framework for using tuples as first-class citizens in Java.
package com.mmnaseri.utils.tuples.facade;
import com.mmnaseri.utils.tuples.FixedTuple;
import com.mmnaseri.utils.tuples.Tuple;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
* Defines methods that work with the eighth element of a {@link FixedTuple}.
*
* @param the super-type of the tuple's main data type.
* @param the type of the object at the eighth position.
* @param the concrete type of the fixed-size tuple.
* @author Milad Naseri ([email protected])
*/
public interface HasEighth> extends FixedTuple {
/** Returns the eighth element in the current tuple. */
@SuppressWarnings("unchecked")
default A eighth() {
return (A) get(7);
}
/** Sets the eighth element of the tuple to the indicated value. */
Tuple eighth(X value);
/** Sets the eighth element of the tuple to the supplied value. */
Tuple eighth(Supplier supplier);
/** Sets the eighth element of the tuple to the value returned from the function. */
Tuple eighth(Function function);
/** Drops the eighth element of the tuple, to return a tuple of one size smaller. */
Tuple dropEighth();
/** Checks to see if the eighth element of this tuple matches the given predicate. */
default boolean checkEighth(Predicate predicate) {
return predicate.test(eighth());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy