Klasse MapComparator

java.lang.Object
de.dlr.proseo.ui.gui.service.MapComparator
Alle implementierten Schnittstellen:
Comparator<Object>

public class MapComparator extends Object implements Comparator<Object>
A class for comparing HashMap objects based on one or two specified keys
Autor:
Ernst Melchinger
  • Felddetails

    • key

      String key
      the first key to compare
    • key2

      String key2
      the second key to compare
    • up

      the sorting order
  • Konstruktordetails

    • MapComparator

      public MapComparator(String key, Boolean up)
      Constructor that takes a key and a boolean argument for the sorting order
      Parameter:
      key - the key to look for in compared hash maps
      up - true, if the comparison is to be made in ascending order, false otherwise
    • MapComparator

      public MapComparator(String key, String key2, Boolean up)
      Constructor that takes two keys and a boolean argument for the sorting order
      Parameter:
      key - the key to look for in compared hash maps
      key2 - the second key to look for
      up - true, if the comparison is to be made in ascending order, false otherwise
  • Methodendetails

    • compare

      public int compare(Object object1, Object object2)
      Compares two objects, checks whether they are instances of HashMap and then extracts the values associated with the specified keys from each HashMap.
      Angegeben von:
      compare in Schnittstelle Comparator<Object>
      Parameter:
      object1 - the first object (HashMap) to compare
      object2 - the second object (HashMap) to compare
      Gibt zurück:
      a negative value if the first object should be placed before the second object, a positive value if the first object should be placed after the second object, or zero if the objects are either not HashMaps, or null, or their keys neither integer nor string, or considered equal in terms of sorting