001package Torello.Java.Additional;
002
003/**
004 * This simple generic-class allows a function to return <B STYLE='color:red'>seven</B> objects as
005 * a result, instead of just one.   This is not always so useful, and can make code confusing.
006 * However there are some instances where the only alternative would be to create an entirely new
007 * class/object, when only a single method result would use that object.
008 *
009 * <BR /><BR /><B CLASS=JDDescLabel>Field Name Change:</B>
010 * 
011 * <BR />For the classes {@link Ret6}, {@code Ret7} &amp; {@link Ret8} - the field names include a
012 * number as well (see {@link #a1}, {@link #b2}, {@link #c3} etc...).  This is simply due to the
013 * fact that these Field-Names become progressively more difficult to read or even look at after
014 * the first four or five letters - {@code 'a', 'b', 'c', 'd'} and {@code 'e'}.
015 * 
016 * <EMBED CLASS=globalDefs DATA-KIND=Ret DATA-N=7>
017 * <EMBED CLASS='external-html' DATA-FILE-ID=IMMUTABLE_RET>
018 * @param <A1> The type of the <B STYLE='color:red'>first</B> member-field ('{@link #a1}').
019 * @param <B2> The type of the <B STYLE='color:red'>second</B> member-field ('{@link #b2}').
020 * @param <C3> The type of the <B STYLE='color:red'>third</B> member-field ('{@link #c3}').
021 * @param <D4> The type of the <B STYLE='color:red'>fourth</B> member-field ('{@link #d4}').
022 * @param <E5> The type of the <B STYLE='color:red'>fifth</B> member-field ('{@link #e5}').
023 * @param <F6> The type of the <B STYLE='color:red'>sixth</B> member-field ('{@link #f6}').
024 * @param <G7> The type of the <B STYLE='color:red'>last</B> member-field ('{@link #g7}').
025 */
026public class Ret7<A1, B2, C3, D4, E5, F6, G7>
027    extends RetN
028    implements java.io.Serializable, Cloneable
029{
030    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID>  */
031    protected static final long serialVersionUID = 1;
032
033    /** This holds a pointer the first response object. */
034    public final A1 a1;
035
036    /** This holds a pointer to the second response object. */
037    public final B2 b2;
038
039    /** This holds a pointer to the third response object. */
040    public final C3 c3;
041
042    /** This holds a pointer to the fourth response object. */
043    public final D4 d4;
044
045    /** This holds a pointer to the fifth response object. */
046    public final E5 e5;
047
048    /** This holds a pointer to the sixth response object. */
049    public final F6 f6;
050
051    /** This holds a pointer to the seventh response object. */
052    public final G7 g7;
053
054    /** Constructs this object */
055    public Ret7(A1 a1, B2 b2, C3 c3, D4 d4, E5 e5, F6 f6, G7 g7)
056    {
057        this.a1 = a1;
058        this.b2 = b2;
059        this.c3 = c3;
060        this.d4 = d4;
061        this.e5 = e5;
062        this.f6 = f6;
063        this.g7 = g7;
064    }
065
066    /**
067     * Returns {@code '7'}, indicating how many fields are declared by this class.
068     * @return As an instance of {@code Ret7}, this method returns {@code '7'};
069     */
070    public int n() { return 7; }
071
072
073    // Super-class uses this for toString, equals, and hashCode
074    // There is an optimization, so if this is requested multiple times, it is saved in a
075    // transient field.
076
077    final Object[] asArrayInternal()
078    { return new Object[] { a1, b2, c3, d4, e5, f6, g7 }; }
079
080    public Ret7<A1, B2, C3, D4, E5, F6, G7> clone()
081    { return new Ret7<>(this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7); }
082
083    /**
084     * <EMBED CLASS=defs DATA-TEXT=", TagNode">
085     * <EMBED CLASS='external-html' DATA-FILE-ID=MULTI_TYPE_EX_COMMON>
086     * <EMBED CLASS='external-html' DATA-FILE-ID=MULTI_TYPE_GET_EX_6_8>
087     */
088    public Object get(final int i)
089    {
090        // Throws Exception if i not in [1..7]
091        CHECK_GET(i);
092
093        if (i <= 4) switch (i)
094        {
095            case 1:     return a1;
096            case 2:     return b2;
097            case 3:     return c3;
098            default:    return d4;
099        }
100
101        else switch (i)
102        {
103            case 5:     return e5;
104            case 6:     return f6;
105            default:    return g7;
106        }
107    }
108
109    public Tuple7<A1, B2, C3, D4, E5, F6, G7> toModifiable()
110    { return new Tuple7<>(this.a1, this.b2, this.c3, this.d4, this.e5, this.f6, this.g7); }
111}