Interface Bounds<T extends java.lang.Comparable<T>>

Type Parameters:
T - the type of Bounds
All Superinterfaces:
java.io.Serializable

public interface Bounds<T extends java.lang.Comparable<T>>
extends java.io.Serializable
Describes a pair of lower and upper bounds for a Comparable value.
  • Method Summary

    Modifier and Type Method Description
    static <T extends java.lang.Comparable<T>>
    Bounds<T>
    create​(T lowerBound, T upperBound)
    Create a Bounds with the given lower and upper limits.
    static <T extends java.lang.Comparable<T>>
    Bounds<T>
    fromPair​(org.apache.commons.lang3.tuple.Pair<T,​T> pair)
    Deprecated.
    This method is here for legacy purpose.
    T getLowerBound()  
    T getUpperBound()  
    default T restrict​(T value)
    Restrict the given value within these Bounds.
    default org.apache.commons.lang3.tuple.Pair<T,​T> toPair()
    Deprecated.
    This method is here for legacy purpose.
  • Method Details

    • getLowerBound

      T getLowerBound()
      Returns:
      the lower limit of these Bounds
    • getUpperBound

      T getUpperBound()
      Returns:
      the upper limit of these Bounds
    • restrict

      default T restrict​(T value)
      Restrict the given value within these Bounds. If the value is lower, it is replaced by getLowerBound(). If the value is higher, it is replaced by getUpperBound(). Otherwise it is returned as provided.
      Parameters:
      value - the value to restrict
      Returns:
      the value or one of the limits
    • create

      static <T extends java.lang.Comparable<T>> Bounds<T> create​(T lowerBound, T upperBound)
      Create a Bounds with the given lower and upper limits.
      Type Parameters:
      T - the type of Bounds
      Parameters:
      lowerBound - the lowest limit
      upperBound - the highest limit
      Returns:
      a Bounds with the given limits
    • fromPair

      @Deprecated static <T extends java.lang.Comparable<T>> Bounds<T> fromPair​(org.apache.commons.lang3.tuple.Pair<T,​T> pair)
      Deprecated.
      This method is here for legacy purpose. Do not use since it should disappear soon.
      Utility method to convert a legacy Pair into a Bounds. The resulting Bounds represents the state of the Pair at call time. Later changes of the Pair do not reflect on the previously created Bounds. It allows to not keep a reference on the Pair instance, which can be garbage collected.
      Type Parameters:
      T - the type of elements
      Parameters:
      pair - the Pair to translate
      Returns:
      the resulting Bounds
    • toPair

      @Deprecated default org.apache.commons.lang3.tuple.Pair<T,​T> toPair()
      Deprecated.
      This method is here for legacy purpose. Do not use since it should disappear soon.
      Utility method to convert this Bounds into a legacy Pair. The resulting Pair represents the state of the Bounds at call time. Later changes of the Bounds do not reflect on the previously created Pair. It allows to not keep a reference on the Bounds instance, which can be garbage collected.
      Returns:
      a Pair representing this Bounds