Class Ret1<A>

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

    public class Ret1<A>
    extends RetN
    implements java.io.Serializable, java.lang.Cloneable
    This simple Generic-Class exists mainly for the case where a function or Type-Parameter needs to return a class that inherits RetN, but only has one return-value. Outside of that particular scenario, there isn't much point to a Ret1 instance.

    Immutable, Read-Only
    Classes which inherit Ancestor-Class RetN will always contains fields declared using the 'final' modifier. These classes are, therefore, "Unmodifiable Tuples" - meaning their contents can never change once they have been instantiated.

    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
      Ret1​(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 a Read-Write Tuple, of the same size
      Modifier and Type Method
      Tuple1<A> toModifiable()
       
      Methods: interface java.lang.Cloneable
      Modifier and Type Method
      Ret1<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 Ret1, this method returns '1';
        Code:
        Exact Method Body:
         return 1;
        
      • get

        🡅  🡇     🗕  🗗  🗖
        public A get​(int i)
        Returns this Ret1 instance's only field - field a. This method may only be invoked on an input value of '1', or else it throws. A Ret1 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 Ret1 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 Ret1, and therefore '1' is the only valid value which may " +
             "be passed to 'i'"
         );
        
         return a;
        
      • toModifiable

        🡅     🗕  🗗  🗖
        public Tuple1<AtoModifiable()
        Description copied from class: RetN
        Converts 'this' Read-Only RetN instance into a Read-Write TupleN.
        Specified by:
        toModifiable in class RetN
        Returns:
        A TupleN of the same size, which is a modifiable type whose fields are not decorated with the 'final' modifier - as the fields in this class are.
        Code:
        Exact Method Body:
         return new Tuple1<>(this.a);