Package Torello.Java.Additional
Class Tuple1<A>
- java.lang.Object
-
- Torello.Java.Additional.MultiType
-
- Torello.Java.Additional.TupleN
-
- Torello.Java.Additional.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 classesTuple1
andTuple0
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 sizedTuple
.
Modifiable, Read-Write
Classes which inherit Ancestor-ClassTupleN
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 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/Tuple1.java
- Open New Browser-Tab: Torello/Java/Additional/Tuple1.java
File Size: 2,794 Bytes Line Count: 77 '\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 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()
-
-
-
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
-
-
Constructor Detail
-
Tuple1
-
Tuple1
public Tuple1()
Constructs this object. Initializes the field to null.
-
-
Method Detail
-
n
-
clone
-
get
public A get(int i)
Returns thisTuple1
instance's only field - fielda
. This method may only be invoked on an input value of'1'
, or else it throws. ATuple1
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 thisTuple1
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<A> toImmutable()
Description copied from class:TupleN
- Specified by:
toImmutable
in classTupleN
- 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);
-
-