Class Ret2<A,​B>

  • Type Parameters:
    A - The type of the first member-field ('a').
    B - The type of the second member-field ('b').
    All Implemented Interfaces:
    java.io.Serializable

    public class Ret2<A,​B>
    extends java.lang.Object
    implements java.io.Serializable
    Ret2 - Documentation.

    This simple generic-class allows a function to return two 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.
    See Also:
    Serialized Form




    • Constructor Summary

      Constructors 
      Constructor
      Ret2​(A a, B b)
    • Field Detail

      • serialVersionUID

        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        1
        public static final long serialVersionUID = 1;
        
      • a

        public final A a
        This holds a pointer the first response object.
        Code:
        Exact Field Declaration Expression:
        1
        public final A a;
        
      • b

        public final B b
        This holds a pointer to the second response object.
        Code:
        Exact Field Declaration Expression:
        1
        public final B b;
        
    • Constructor Detail

      • Ret2

        public Ret2​(A a,
                    B b)
        This constructs this object
    • Method Detail

      • main

        public static void main​(java.lang.String[] argv)
        Code:
        Exact Method Body:
        1
        2
        3
        4
        5
        6
        7
        8
         Integer[] p1 = { Integer.valueOf(5), Integer.valueOf(10), Integer.valueOf(15) };
         int[] p2 = { 3, 6, 9 };
         Integer[][] p3 = { };
         int[][] p4 = { };
        
         Ret2<Integer[], int[]> r2 = new Ret2<>(p1, p2);
         Ret2<Integer[][], int[][]> r22 = new Ret2<>(p3, p4);
         System.out.println(r2 + "\n\n" + r22);
        
      • toString

        public java.lang.String toString()
        Converts this instance of Ret2 to a String.
        Overrides:
        toString in class java.lang.Object
        Returns:
        This instance-object as a String.
        Code:
        Exact Method Body:
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
         String[] types = new String[2];
         types[0] = a.getClass().getSimpleName();
         types[1] = b.getClass().getSimpleName();
        
         int maxLen = (types[0].length() > types[1].length())
             ? types[0].length()
             : types[1].length();
        
         maxLen += 2;
        
         return
             "Ret2.a: " + StringParse.rightSpacePad(types[0], maxLen) +
             (a.getClass().isArray()
                 ? RetHelper.toArrayString(a, types[0])
                 : RetHelper.indentIfNeeded(a.toString())) + '\n' +
             "Ret2.b: " + StringParse.rightSpacePad(types[1], maxLen) +
             (b.getClass().isArray()
                 ? RetHelper.toArrayString(b, types[1])
                 : RetHelper.indentIfNeeded(b.toString()));