001package Torello.Java.Additional;
002
003import Torello.Java.StringParse;
004
005/**
006 * <CODE>Ret6 - Documentation.</CODE><BR /><BR />
007 * 
008 * This simple generic-class allows a function to return six objects as a result, instead of just
009 * one.   This is not always so useful, and can make code confusing.  However there are some
010 * instances where the only alternative would be to create an entirely new class/object, when only
011 * a single method result would use that object.
012 *
013 * <BR /><BR /><B>ALSO: </B> For the classes Ret6, Ret7 &amp; Ret8 - the variable name includes a
014 * number as well, since the letters become progressively more difficult to look at as they increase
015 * past "A, B, C, D..."
016 * 
017 * @param <A> The type of the first member-field ({@code 'a1'}).
018 * @param <B> The type of the second member-field ({@code 'b2'}).
019 * @param <C> The type of the third member-field ({@code 'c3'}).
020 * @param <D> The type of the fourth member-field ({@code 'd4'}).
021 * @param <E> The type of the fifth member-field ({@code 'e5'}).
022 * @param <F> The type of the last member-field ({@code 'f6'}).
023 */
024public class Ret6<A, B, C, D, E, F> implements java.io.Serializable
025{
026    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID>  */
027    public static final long serialVersionUID = 1;
028
029    /** This holds a pointer the first response object. */
030    public final A a1;
031
032    /** This holds a pointer to the second response object. */
033    public final B b2;
034
035    /** This holds a pointer to the third response object. */
036    public final C c3;
037
038    /** This holds a pointer to the fourth response object. */
039    public final D d4;
040
041    /** This holds a pointer to the fifth response object. */
042    public final E e5;
043
044    /** This holds a pointer to the sixth response object. */
045    public final F f6;
046
047    /** This constructs this object */
048    public Ret6(A a, B b, C c, D d, E e, F f)
049    {
050        this.a1 = a;
051        this.b2 = b;
052        this.c3 = c;
053
054        this.d4 = d;
055        this.e5 = e;
056        this.f6 = f;
057    }
058
059    /**
060     * Converts this instance of {@code Ret6} to a {@code String}.
061     * @return This instance-object as a {@code String}.
062     */
063    public String toString()
064    {
065        String[] types = new String[6];
066        types[0] = a1.getClass().getSimpleName();
067        types[1] = b2.getClass().getSimpleName();
068        types[2] = c3.getClass().getSimpleName();
069        types[3] = d4.getClass().getSimpleName();
070        types[4] = e5.getClass().getSimpleName();
071        types[5] = f6.getClass().getSimpleName();
072
073        int maxLen  = types[0].length();
074        int len     = 0;
075        for (int i=1; i < 6; i++) if ((len = types[i].length()) > maxLen) maxLen = len;
076
077        maxLen += 2;
078
079        return
080            "Ret6.a1: " + StringParse.rightSpacePad(types[0], maxLen) +
081            (a1.getClass().isArray()
082                ? RetHelper.toArrayString(a1, types[0])
083                : RetHelper.indentIfNeeded(a1.toString())) + '\n' +
084            "Ret6.b2: " + StringParse.rightSpacePad(types[1], maxLen) +
085            (b2.getClass().isArray()
086                ? RetHelper.toArrayString(b2, types[1])
087                : RetHelper.indentIfNeeded(b2.toString())) + '\n' +
088            "Ret6.c3: " + StringParse.rightSpacePad(types[2], maxLen) +
089            (c3.getClass().isArray()
090                ? RetHelper.toArrayString(c3, types[2])
091                : RetHelper.indentIfNeeded(c3.toString())) + '\n' +
092            "Ret6.d4: " + StringParse.rightSpacePad(types[3], maxLen) +
093            (d4.getClass().isArray()
094                ? RetHelper.toArrayString(d4, types[3])
095                : RetHelper.indentIfNeeded(d4.toString())) + '\n' +
096            "Ret6.e5: " + StringParse.rightSpacePad(types[4], maxLen) +
097            (e5.getClass().isArray()
098                ? RetHelper.toArrayString(e5, types[4])
099                : RetHelper.indentIfNeeded(e5.toString())) + '\n' +
100            "Ret6.f6: " + StringParse.rightSpacePad(types[5], maxLen) +
101            (f6.getClass().isArray()
102                ? RetHelper.toArrayString(f6, types[5])
103                : RetHelper.indentIfNeeded(f6.toString()));
104    }
105
106}