package gw.admin uses java.lang.Comparable uses java.util.Date class FormPatternLookupSortKey implements Comparable { var _lookup : FormPatternLookup as readonly Lookup construct(formPatternLookup : FormPatternLookup) { _lookup = formPatternLookup } override function compareTo(other : FormPatternLookupSortKey) : int { if (this.Lookup.PublicID == other.Lookup.PublicID) { return 0 } // Sort order is ascending, so higher specificity < lower specificity if (this.Specificity != other.Specificity) { return other.Specificity - this.Specificity } if (Lookup.Jurisdiction != null) { var cmp = Lookup.Jurisdiction.compareTo(other.Lookup.Jurisdiction) if (cmp != 0) { return cmp } } if (Lookup.UWCompanyCode != null) { var cmp = Lookup.UWCompanyCode.compareTo(other.Lookup.UWCompanyCode) if (cmp != 0) { return cmp } } var cmp = compareDates(Lookup.StartEffectiveDate, other.Lookup.StartEffectiveDate) if (cmp != 0) { return cmp } if (Lookup.Availability != other.Lookup.Availability) { return (Lookup.Availability == AvailabilityType.TC_UNAVAILABLE) ? -1 : 1 } return 0 } function compareDates(thisDate : Date, otherDate : Date) : int { if (thisDate == otherDate) { return 0 } if (thisDate == null) { return -1 } if (otherDate == null) { return 1 } return thisDate.compareTo(otherDate) } property get Specificity() : int { var total = 0 if (Lookup.Jurisdiction != null) { total += 2 } if (Lookup.UWCompanyCode != null) { total += 1 } return total } }