Package Torello.Java.Additional
Class Ret1<A>
- java.lang.Object
-
- Torello.Java.Additional.MultiType
-
- Torello.Java.Additional.RetN
-
- Torello.Java.Additional.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 inheritsRetN, but only has one return-value. Outside of that particular scenario, there isn't much point to aRet1instance.Immutable, Read-Only: Classes which inherit Ancestor-ClassRetNwill 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 classesRet1andTuple1completely identical, with the sole difference being thatRet1fields are all declared'final', but theTuple1fields are not!- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/Ret1.java
- Open New Browser-Tab: Torello/Java/Additional/Ret1.java
File Size: 2,611 Bytes Line Count: 71 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field protected static longserialVersionUIDInstance Fields Modifier and Type Field Aa
-
Method Summary
Retrieve the Number of Fields in this Class Modifier and Type Method intn()Retrieve a Field by Field-Number Modifier and Type Method Aget(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()
-
-
-
Field Detail
-
serialVersionUID
protected static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation 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;
-
a
-
-
Method Detail
-
n
-
clone
-
get
public A get(int i)
Returns thisRet1instance's only field - fielda. This method may only be invoked on an input value of'1', or else it throws. ARet1instance has only a single field that may be retrieved.
This method must be included to properly, fully, implement the ancestorMultiTypeinterface.- Specified by:
getin classMultiType- Parameters:
i- This must be passed'1', or else this method throws IOOBEX.- Returns:
- This returns the
ithfield of this class. - Throws:
java.lang.IndexOutOfBoundsException- As thisRet1instance 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<A> toModifiable()
Description copied from class:RetN- Specified by:
toModifiablein classRetN- Returns:
- A
TupleNof 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);
-
-