1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | package Torello.Java.Additional; import java.lang.reflect.Field; /** * This simple generic-class allows for storing <B STYLE='color:red'>eight</B> objects with a * single reference. * * <BR /><BR /><B CLASS=JDDescLabel>Field Name Change:</B> * * <BR />For the classes {@link Tuple6}, {@link Tuple7} & {@code Tuple8} - the field names * include a number as well (see {@link #a1}, {@link #b2}, {@link #c3} etc...). This is simply due * to the fact that these Field-Names become progressively more difficult to read or even look at * after the first four or five letters - {@code 'a', 'b', 'c', 'd'} and {@code 'e'}. * * <EMBED CLASS=globalDefs DATA-KIND=Tuple DATA-N=8> * <EMBED CLASS='external-html' DATA-FILE-ID=MUTABLE_TUPLE> * @param <A1> The type of the <B STYLE='color:red'>first</B> member-field ('{@link #a1}'). * @param <B2> The type of the <B STYLE='color:red'>second</B> member-field ('{@link #b2}'). * @param <C3> The type of the <B STYLE='color:red'>third</B> member-field ('{@link #c3}'). * @param <D4> The type of the <B STYLE='color:red'>fourth</B> member-field ('{@link #d4}'). * @param <E5> The type of the <B STYLE='color:red'>fifth</B> member-field ('{@link #e5}'). * @param <F6> The type of the <B STYLE='color:red'>sixth</B> member-field ('{@link #f6}'). * @param <G7> The type of the <B STYLE='color:red'>seventh</B> member-field ('{@link #g7}'). * @param <H8> The type of the <B STYLE='color:red'>last</B> member-field ('{@link #h8}'). */ public class Tuple8<A1, B2, C3, D4, E5, F6, G7, H8> extends TupleN implements java.io.Serializable, Cloneable { /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ protected static final long serialVersionUID = 1; /** This holds a pointer the first field / instance. */ public A1 a1; /** This holds a pointer to the second field / instance. */ public B2 b2; /** This holds a pointer to the third field / instance. */ public C3 c3; /** This holds a pointer to the fourth field / instance. */ public D4 d4; /** This holds a pointer to the fifth field / instance. */ public E5 e5; /** This holds a pointer to the sixth field / instance. */ public F6 f6; /** This holds a pointer to the seventh field / instance. */ public G7 g7; /** This holds a pointer to the seventh field / instance. */ public H8 h8; /** Constructs this object */ public Tuple8(A1 a1, B2 b2, C3 c3, D4 d4, E5 e5, F6 f6, G7 g7, H8 h8) { this.a1 = a1; this.b2 = b2; this.c3 = c3; this.d4 = d4; this.e5 = e5; this.f6 = f6; this.g7 = g7; this.h8 = h8; } /** Constructs this object. Initializes all fields to null. */ public Tuple8() { this.a1 = null; this.b2 = null; this.c3 = null; this.d4 = null; this.e5 = null; this.f6 = null; this.g7 = null; this.h8 = null; } /** * Returns {@code '8'}, indicating how many fields are declared by this class. * @return As an instance of {@code Tuple8}, this method returns {@code '8'}; */ public int n() { return 8; } // Super-class uses this for toString, equals, and hashCode // There is an optimization, so if this is requested multiple times, it is saved in a // transient field. final Object[] asArrayInternal() { return new Object[] { a1, b2, c3, d4, e5, f6, g7, h8 }; } public Tuple8<A1, B2, C3, D4, E5, F6, G7, H8> clone() { return new Tuple8<> (this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7, this.h8); } /** * <EMBED CLASS=defs DATA-TEXT=", TagNode, TextNode"> * <EMBED CLASS='external-html' DATA-FILE-ID=MULTI_TYPE_EX_COMMON> * <EMBED CLASS='external-html' DATA-FILE-ID=MULTI_TYPE_GET_EX_6_8> */ public Object get(final int i) { // Throws Exception if i not in [1..8] CHECK_GET(i); if (i <= 4) switch (i) { case 1: return a1; case 2: return b2; case 3: return c3; default: return d4; } else switch (i) { case 5: return e5; case 6: return f6; case 7: return g7; default: return h8; } } public Ret8<A1, B2, C3, D4, E5, F6, G7, H8> toImmutable() { return new Ret8<> (this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7, this.h8); } } |