Class Ordered<T>

java.lang.Object
io.jenetics.util.Ordered<T>
Type Parameters:
T - the type of the wrapped object
All Implemented Interfaces:
Comparable<Ordered<T>>, Supplier<T>

public final class Ordered<T> extends Object implements Comparable<Ordered<T>>, Supplier<T>
Object wrapper, which makes the wrapped value Comparable, by defining a separate Comparator.
Since:
6.3
Version:
6.3
  • Method Details

    • get

      public T get()
      Return the wrapped value.
      Specified by:
      get in interface Supplier<T>
      Returns:
      the wrapped value
    • compareTo

      public int compareTo(Ordered<T> other)
      Specified by:
      compareTo in interface Comparable<T>
    • of

      public static <T> Ordered<T> of(T value, Comparator<? super T> comparator)
      Make the given value comparable, by using the given comparator.
      Type Parameters:
      T - the type of the wrapped object
      Parameters:
      value - the wrapped object, may be null
      comparator - the comparator used for comparing two value objects
      Returns:
      a new ordered object
      Throws:
      NullPointerException - if the given comparator is null