Class Triple<A,​B,​C>

  • Type Parameters:
    A - first object in triple
    B - second object in triple
    C - second object in triple

    public class Triple<A,​B,​C>
    extends Object
    Custom Triple class similar to Pair, only with three entries. value
    Author:
    markr
    • Field Detail

      • first

        protected final A first
        The first object in this Triple
      • second

        protected final B second
        The second object in this Triple
      • third

        protected final C third
        The third object in this Triple
    • Constructor Detail

      • Triple

        protected Triple​(A first,
                         B second,
                         C third)
        Constructor
        Parameters:
        first - first object in triple
        second - second object in triple
        third - second object in triple
    • Method Detail

      • of

        public static <A,​B,​C> Triple<A,​B,​C> of​(A valueA,
                                                                       B valueB,
                                                                       C valueC)
        Factory method
        Type Parameters:
        A - type of valueA
        B - type of valueB
        C - type of valueC
        Parameters:
        valueA - first
        valueB - second
        valueC - third
        Returns:
        new triple
      • equals

        public boolean equals​(Object other)
        Check equality to another triple
        Overrides:
        equals in class Object
        Parameters:
        other - triple being compared to
        See Also:
        Object.equals(Object)
      • copy

        public Triple<A,​B,​C> copy()
        shallow copy of this triple
        Returns:
        shallow copy
      • first

        public A first()
        Get first object in triple
        Returns:
        first object in triple
      • second

        public B second()
        Get second object in triple
        Returns:
        second object in triple
      • third

        public C third()
        Get second object in triple
        Returns:
        second object in triple
      • anyIsNotNull

        public boolean anyIsNotNull()
        check if any of the two values is not null
        Returns:
        true when one of the entries is not null
      • allNotNull

        public boolean allNotNull()
        check if all values are not null
        Returns:
        true when both entries are not null
      • anyIsNull

        public boolean anyIsNull()
        check if any values are null
        Returns:
        true when any are null, false otherwise
      • getEarliestNonNull

        public Object getEarliestNonNull()
        Returns:
        earliest entry (first before second) that is nonNull, when both are null, null is returned
      • both

        public <T> void both​(Consumer<T> tripleEntryConsumer)
        Apply consumer all entries. Throws ClassCastException when triple contains entries not compatible with type parameter of consumer
        Type Parameters:
        T - consumer type assumed to be compatible with both triple entries
        Parameters:
        tripleEntryConsumer - to apply
      • firstNotNull

        public boolean firstNotNull()
        Check if first is non-null
        Returns:
        true when the case, false otherwise
      • secondNotNull

        public boolean secondNotNull()
        Check if second is non-null
        Returns:
        true when the case, false otherwise
      • thirdNotNull

        public boolean thirdNotNull()
        Check if third is non-null
        Returns:
        true when the case, false otherwise
      • different

        public boolean different()
        Check if entries are not equal
        Returns:
        true when first does not equal second, false otherwise
      • allNull

        public boolean allNull()
        check all are null
        Returns:
        true when both null, false otherwise