Class Tuple1<A>

  • Type Parameters:
    A - The type of the only member-field ('a').
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class Tuple1<A>
    extends TupleN
    implements java.io.Serializable, java.lang.Cloneable
    The classes Tuple1 and Tuple0 are here merely for the convenience and the possibility that an unknown sized tuple might be needed, and on occasion that unknown sized reference would contain only one (or even zero) elements.

    There are otherwise very few uses for a 1 or 0 sized Tuple.

    Modifiable, Read-Write
    Classes which inherit Ancestor-Class TupleN will always contains fields which are not declared using the 'final' modifier. These classes are, therefore, "Mutable Tuples" - meaning their contents may be changed whenever necessary.

    Remember: The classes Ret1 and Tuple1 completely identical, with the sole difference being that Ret1 fields are all declared final, but the Tuple1 fields are not!
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      protected static long serialVersionUID
       
      Instance Fields
      Modifier and Type Field
      A a
    • Constructor Summary

      Constructors 
      Constructor Description
      Tuple1()
      Constructs this object.
      Tuple1​(A a)
      Constructs this object
    • Method Summary

       
      Retrieve the Number of Fields in this Class
      Modifier and Type Method
      int n()
       
      Retrieve a Field by Field-Number
      Modifier and Type Method
      A get​(int i)
       
      Convert this instance to an Immutable RetN instance, of the same size
      Modifier and Type Method
      Ret1<A> toImmutable()
       
      Methods: interface java.lang.Cloneable
      Modifier and Type Method
      Tuple1<A> clone()
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        protected static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         protected static final long serialVersionUID = 1;
        
    • Method Detail

      • n

        🡅  🡇     🗕  🗗  🗖
        public int n()
        Returns '1', indicating how many fields are declared by this class.
        Specified by:
        n in class MultiType
        Returns:
        As an instance of Tuple1, this method returns '1';
        Code:
        Exact Method Body:
         return 1;
        
      • get

        🡅  🡇     🗕  🗗  🗖
        public A get​(int i)
        Returns this Tuple1 instance's only field - field a. This method may only be invoked on an input value of '1', or else it throws. A Tuple1 instance has only a single field that may be retrieved.

        This method must be included to properly, fully, implement the ancestor MultiType interface.
        Specified by:
        get in class MultiType
        Parameters:
        i - This must be passed '1', or else this method throws IOOBEX.
        Returns:
        This returns the ith field of this class.
        Throws:
        java.lang.IndexOutOfBoundsException - As this Tuple1 instance has but a single field, this exceptions throws for all values of 'i' - except '1'.
        See Also:
        MultiType.get(int, Class), MultiType.GET(int)
        Code:
        Exact Method Body:
         if (i != 1) throw new IndexOutOfBoundsException(
             "This is an instance of Tuple1, and therefore '1' is the only valid value which may " +
             "be passed to 'i'"
         );
        
         return a;
        
      • toImmutable

        🡅     🗕  🗗  🗖
        public Ret1<AtoImmutable()
        Description copied from class: TupleN
        Converts 'this' Modifiable TupleN instance into a Read-Only RetN.
        Specified by:
        toImmutable in class TupleN
        Returns:
        A RetN of the same size, which is an immutable type whose fields have been decorated with the 'final' modifier - and therefore cannot be changed once the instance has been constructed.
        Code:
        Exact Method Body:
         return new Ret1<>(this.a);