Class Person.Order

java.lang.Object
cs1302.oracle.model.Person.Order
Enclosing class:
Person

public static class Person.Order extends Object
Implementations of Comparable<Person> that impose various orderings.
  • Method Details

    • by

      public static <R extends Comparable<? super R>> Comparator<Person> by(Person.Mapper<R> mapper)
      Returns a comparator for Person objects that performs comparisons using the natural ordering of the results of applying the given mapper function to the person objects under comparison.
      Type Parameters:
      R - the return type of mapper.apply(Person)
      Parameters:
      mapper - a function that returns a comparable value for a person
      Returns:
      a comparator for Person objects
    • byAge

      public static Comparator<Person> byAge()
      Returns a comparator for Person objects that performs comparisons using the natural ordering of the age values of the person objects under comparison.
      Returns:
      a comparator that compares Person objects by age
    • byName

      public static Comparator<Person> byName()
      Returns a comparator for Person objects that performs comparisons using the natural ordering of the name values of the person objects under comparision.
      Returns:
      a comparator that compares Person objects by name
    • naturally

      public static Comparator<Person> naturally()
      Returns a comparator for Person objects that performs comparisons according to the natural ordering of the person objects under comparision.
      Returns:
      a comparator that compares Person objects naturally