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 | package Torello.Java.Additional; /** * This simple generic-class allows a function to return <B STYLE='color:red'>seven</B> objects as * a result, instead of just one. This is not always so useful, and can make code confusing. * However there are some instances where the only alternative would be to create an entirely new * class/object, when only a single method result would use that object. * * <BR /><BR /><B CLASS=JDDescLabel>Field Name Change:</B> * * <BR />For the classes {@link Ret6}, {@code Ret7} & {@link Ret8} - 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=Ret DATA-N=7> * <EMBED CLASS='external-html' DATA-FILE-ID=IMMUTABLE_RET> * @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'>last</B> member-field ('{@link #g7}'). */ public class Ret7<A1, B2, C3, D4, E5, F6, G7> extends RetN 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 response object. */ public final A1 a1; /** This holds a pointer to the second response object. */ public final B2 b2; /** This holds a pointer to the third response object. */ public final C3 c3; /** This holds a pointer to the fourth response object. */ public final D4 d4; /** This holds a pointer to the fifth response object. */ public final E5 e5; /** This holds a pointer to the sixth response object. */ public final F6 f6; /** This holds a pointer to the seventh response object. */ public final G7 g7; /** Constructs this object */ public Ret7(A1 a1, B2 b2, C3 c3, D4 d4, E5 e5, F6 f6, G7 g7) { this.a1 = a1; this.b2 = b2; this.c3 = c3; this.d4 = d4; this.e5 = e5; this.f6 = f6; this.g7 = g7; } /** * Returns {@code '7'}, indicating how many fields are declared by this class. * @return As an instance of {@code Ret7}, this method returns {@code '7'}; */ public int n() { return 7; } // 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 }; } public Ret7<A1, B2, C3, D4, E5, F6, G7> clone() { return new Ret7<>(this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7); } /** * <EMBED CLASS=defs DATA-TEXT=", TagNode"> * <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..7] 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; default: return g7; } } public Tuple7<A1, B2, C3, D4, E5, F6, G7> toModifiable() { return new Tuple7<>(this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7); } } |