public class SecurityRuleComparator implements Comparator<MotechURLSecurityRule>

Class that helps to compare



public int compare(MotechURLSecurityRule o1, MotechURLSecurityRule o2)

Compares two MotechURLSecurityRules to select more important one (one with higher priority or one that comes from the system or one with longer pattern). First checks if both priorities are the same, if yes then checks for origin of both rules. If both of origins equals or if none of them then compares length of patterns from both rules. If origin of only one of the rules is equal then returns number that represents given rule. If priorities of both rules are not the same then just compares them.

  • o1 – first rule
  • o2 – second rule

number that represents one of the rules - will return 1 if first rule is more important or -1 if the second one