java.lang.Object
dk.cloudcreate.essentials.shared.functional.tuple.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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final T1
    The first element in this tuple
  • Constructor Summary

    Constructors
    Constructor
    Description
    Single(T1 t1)
    Create a new Tuple with 1 element
  • Method Summary

    Modifier and Type
    Method
    Description
    _1()
    Returns the first element in this tuple
    int
    Number of arguments/elements in the Tuple
    boolean
     
    int
     
    <R1> Single<R1>
    map(Function<? super T1,? extends R1> mappingFunction)
    Maps the element of this Single using the mapping function
    List<?>
    Convert the Tuple to a list
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • _1

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

    • Single

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

    • 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
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object