Class DictComparator

java.lang.Object
org.rapidcontext.core.data.DictComparator
All Implemented Interfaces:
Comparator<Object>

public class DictComparator extends Object implements Comparator<Object>
A dictionary value comparator. This comparator only compares the values of two dictionary keys. All values returned which must implement Comparable and be of compatible types.
Version:
1.0
  • Constructor Details

    • DictComparator

      public DictComparator(String key)
      Creates a new dictionary comparator.
      Parameters:
      key - the dictionary key name
  • Method Details

    • compare

      public int compare(Object o1, Object o2) throws ClassCastException
      Compares two dictionaries by comparing their values for a predefined property key.
      Specified by:
      compare in interface Comparator<Object>
      Parameters:
      o1 - the first object
      o2 - the second object
      Returns:
      a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
      Throws:
      ClassCastException - if the values were not comparable