Class Single<T1>

  • Type Parameters:
    T1 - the first element type
    All Implemented Interfaces:
    Tuple<Single<T1>>, Serializable

    public class Single<T1>
    extends Object
    implements Tuple<Single<T1>>
    Represents a Tuple with one element.
    Note: Single supports equals(Object) comparison using subclasses, e.g.:
    
     public class Option extends Single<String> {
         public Option(String optionalValue) {
           super(optionalValue);
         }
     }
     
    See Also:
    Serialized Form
    • Field Detail

      • _1

        public final T1 _1
        The first element in this tuple
    • Constructor Detail

      • Single

        public Single​(T1 t1)
        Create a new Tuple with 1 element
        Parameters:
        t1 - the first element
    • Method Detail

      • arity

        public int arity()
        Description copied from interface: Tuple
        Number of arguments/elements in the Tuple
        Specified by:
        arity in interface Tuple<T1>
        Returns:
        Number of arguments/elements in the Tuple
      • toList

        public List<?> toList()
        Description copied from interface: Tuple
        Convert the Tuple to a list
        Specified by:
        toList in interface Tuple<T1>
        Returns:
        list of all Tuple elements
      • _1

        public T1 _1()
        Returns the first element in this tuple
        Returns:
        the first element in this tuple
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • map

        public <R1> Single<R1> map​(Function<? super T1,​? extends R1> mappingFunction)
        Maps the element of this Single using the mapping function
        Type Parameters:
        R1 - result type for the mapping function
        Parameters:
        mappingFunction - the mapping function
        Returns:
        a new Single with the result of applying the mapping function to this Single