1 package org.jahia.content; 2 3 import java.util.Comparator ; 4 5 import org.jahia.utils.JahiaConsole; 6 import java.io.Serializable ; 7 8 17 18 public class ObjectKeyComparator implements Comparator , Serializable { 19 20 public ObjectKeyComparator() { 21 } 22 23 public int compare(Object o1, Object o2) { 24 if ((o1 instanceof ObjectKey) && (o2 instanceof ObjectKey)) { 25 ObjectKey key1 = (ObjectKey) o1; 26 ObjectKey key2 = (ObjectKey) o2; 27 return key1.getKey().compareTo(key2.getKey()); 28 } else { 29 JahiaConsole.println("ObjectKeyComparator.compare", 30 "Comparator called on non ObjectKey objects, returning -1..."); 31 return -1; } 33 } 34 35 40 public boolean equals(Object obj) { 41 if (obj instanceof ObjectKeyComparator) { 42 return true; 43 } else { 44 return false; 45 } 46 } 47 } 48 | Popular Tags |