Class CmsPair<A,​B>

  • Type Parameters:
    A - type of the first component of the pair
    B - type of the second component of the pair
    All Implemented Interfaces:
    java.io.Serializable

    public class CmsPair<A,​B>
    extends java.lang.Object
    implements java.io.Serializable
    Generic pair class.

    Since:
    8.0.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CmsPair()
      Serialization constructor.
      CmsPair​(A a, B b)
      Creates a new pair containing two objects.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <A,​B>
      CmsPair<A,​B>
      create​(A a, B b)
      Helper method for constructing a pair which avoids having to explicitly write the generic type parameters.
      boolean equals​(java.lang.Object o)  
      A getFirst()
      Returns the first component of the pair.
      static <A extends java.lang.Comparable<A>,​B extends java.lang.Comparable<B>>
      java.util.Comparator<CmsPair<A,​B>>
      getLexicalComparator()
      Utility method which creates a new comparator for lexically ordering pairs.
      B getSecond()
      Returns the second component of the pair.
      int hashCode()  
      static java.util.Map<java.lang.String,​java.lang.String> pairsToMap​(java.util.List<CmsPair<java.lang.String,​java.lang.String>> pairs)
      Helper method for converting a list of string pairs to a string map.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CmsPair

        public CmsPair()
        Serialization constructor.

      • CmsPair

        public CmsPair​(A a,
                       B b)
        Creates a new pair containing two objects.

        Parameters:
        a - the first component
        b - the second component
    • Method Detail

      • create

        public static <A,​B> CmsPair<A,​B> create​(A a,
                                                            B b)
        Helper method for constructing a pair which avoids having to explicitly write the generic type parameters.

        Type Parameters:
        A - the type for the first component
        B - the type for the second component
        Parameters:
        a - the first component
        b - the second component
        Returns:
        the pair (a, b)
      • getLexicalComparator

        public static <A extends java.lang.Comparable<A>,​B extends java.lang.Comparable<B>> java.util.Comparator<CmsPair<A,​B>> getLexicalComparator()
        Utility method which creates a new comparator for lexically ordering pairs.

        Lexical ordering means that a pair is considered "less" than another if either its first component is less than that of the other one, or their first components are equal and the second component of the first pair is less than that of the other one.

        Type Parameters:
        A - the type parameter for the first pair component
        B - the type parameter for the second pair component
        Returns:
        a new comparator for lexically ordering pairs
      • pairsToMap

        public static java.util.Map<java.lang.String,​java.lang.String> pairsToMap​(java.util.List<CmsPair<java.lang.String,​java.lang.String>> pairs)
        Helper method for converting a list of string pairs to a string map.

        The first component of each pair is used as a map key, the second component as the value for the key.

        Parameters:
        pairs - the list of pairs
        Returns:
        a string map
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • getFirst

        public A getFirst()
        Returns the first component of the pair.

        Returns:
        the first component of the pair
      • getSecond

        public B getSecond()
        Returns the second component of the pair.

        Returns:
        the second component of the pair
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()