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
package Torello.Java.Additional;

import Torello.Java.StringParse;

/**
 * <CODE>Ret4 - Documentation.</CODE><BR /><BR />
 * 
 * This simple generic-class allows a function to return four 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.
 * 
 * @param <A> The type of the first member-field ({@code 'a'}).
 * @param <B> The type of the second member-field ({@code 'b'}).
 * @param <C> The type of the third member-field ({@code 'c'}).
 * @param <D> The type of the last member-field ({@code 'd'}).
 */
public class Ret4<A, B, C, D> implements java.io.Serializable
{
    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID>  */
    public static final long serialVersionUID = 1;

    /** This holds a pointer the first response object. */
    public final A a;

    /** This holds a pointer to the second response object. */
    public final B b;

    /** This holds a pointer to the third response object. */
    public final C c;

    /** This holds a pointer to the fourth response object. */
    public final D d;

    /** This constructs this object */
    public Ret4(A a, B b, C c, D d)
    {
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
    }

    /**
     * Converts this instance of {@code Ret4} to a {@code String}.
     * @return This instance-object as a {@code String}.
     */
    public String toString()
    {
        String[] types = new String[4];
        types[0] = a.getClass().getSimpleName();
        types[1] = b.getClass().getSimpleName();
        types[2] = c.getClass().getSimpleName();
        types[3] = d.getClass().getSimpleName();

        int maxLen  = types[0].length();
        int len     = 0;
        for (int i=1; i < 4; i++) if ((len = types[i].length()) > maxLen) maxLen = len;

        maxLen += 2;

        return
            "Ret4.a: " + StringParse.rightSpacePad(types[0], maxLen) +
            (a.getClass().isArray()
                ? RetHelper.toArrayString(a, types[0])
                : RetHelper.indentIfNeeded(a.toString())) + '\n' +
            "Ret4.b: " + StringParse.rightSpacePad(types[1], maxLen) +
            (b.getClass().isArray()
                ? RetHelper.toArrayString(b, types[1])
                : RetHelper.indentIfNeeded(b.toString())) + '\n' +
            "Ret4.c: " + StringParse.rightSpacePad(types[2], maxLen) +
            (c.getClass().isArray()
                ? RetHelper.toArrayString(c, types[2])
                : RetHelper.indentIfNeeded(c.toString())) + '\n' +
            "Ret4.d: " + StringParse.rightSpacePad(types[3], maxLen) +
            (d.getClass().isArray()
                ? RetHelper.toArrayString(d, types[3])
                : RetHelper.indentIfNeeded(d.toString()));
    }

}