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 aRet1
instance.
Immutable, Read-Only
Classes which inherit Ancestor-ClassRetN
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 classesRet1
andTuple1
completely identical, with the sole difference being thatRet1
fields are all declared final, but theTuple1
fields 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,610 Bytes Line Count: 70 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field protected static long
serialVersionUID
Instance Fields Modifier and Type Field A
a
-
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()
-
-
-
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 theSerializable
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;
-
a
-
-
Method Detail
-
n
-
clone
-
get
public A get(int i)
Returns thisRet1
instance's only field - fielda
. This method may only be invoked on an input value of'1'
, or else it throws. ARet1
instance has only a single field that may be retrieved.
This method must be included to properly, fully, implement the ancestorMultiType
interface.- Specified by:
get
in classMultiType
- 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 thisRet1
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<A> toModifiable()
Description copied from class:RetN
- Specified by:
toModifiable
in classRetN
- 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);
-
-