1 package org.kuali.common.devops.model; 2 3 import java.util.Comparator; 4 5 import com.google.common.base.Joiner; 6 import com.google.common.base.Splitter; 7 import com.google.common.collect.Lists; 8 9 public class FqdnComparator implements Comparator<String> { 10 11 private static final char SEPARATOR = '.'; 12 private static final Splitter SPLITTER = Splitter.on(SEPARATOR); 13 private static final Joiner JOINER = Joiner.on(SEPARATOR); 14 15 @Override 16 public int compare(String fqdn1, String fqdn2) { 17 String r1 = reverse(fqdn1); 18 String r2 = reverse(fqdn2); 19 return r1.compareTo(r2); 20 } 21 22 protected String reverse(String fqdn) { 23 return JOINER.join(Lists.reverse(SPLITTER.splitToList(fqdn))); 24 } 25 26 }