Class Tuple4<A,​B,​C,​D>

  • All Implemented Interfaces:
    Serializable

    public class Tuple4<A,​B,​C,​D>
    extends Object
    implements Serializable
    Holds 4 items of potentially different types. Designed to let you easily create immutable subclasses (to give your data structures meaningful names) with correct equals(), hashCode(), and toString() methods.
    See Also:
    Serialized Form
    • Field Detail

      • _1

        protected final A _1
      • _2

        protected final B _2
      • _3

        protected final C _3
      • _4

        protected final D _4
    • Constructor Detail

      • Tuple4

        protected Tuple4​(A a,
                         B b,
                         C c,
                         D d)
        Constructor is protected (not public) for easy inheritance. Josh Bloch's "Item 1" says public static factory methods are better than constructors because they have names, they can return an existing object instead of a new one, and they can return a subtype. Therefore, you have more flexibility with a static factory as part of your public API then with a public constructor.
    • Method Detail

      • of

        @NotNull
        public static <A,​B,​C,​D> @NotNull Tuple4<A,​B,​C,​D> of​(A a,
                                                                                                B b,
                                                                                                C c,
                                                                                                D d)
        Public static factory method
      • _1

        public A _1()
        Returns the 1st field
      • _2

        public B _2()
        Returns the 2nd field
      • _3

        public C _3()
        Returns the 3rd field
      • _4

        public D _4()
        Returns the 4th field
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object