@Test public void testCompare() throws Exception { DeleterThreshold threshold1 = DeleterThreshold.valueOf("10_[hour=18-6]10GB"); DeleterThreshold threshold2 = DeleterThreshold.valueOf("20_[dayOfWeek=0,6]10GB"); DeleterThreshold threshold3 = DeleterThreshold.valueOf("1GB"); DeleterThreshold[] thresholds = { threshold3, threshold2, threshold1 }; Arrays.sort(thresholds); assertSame(threshold1, thresholds[0]); assertSame(threshold2, thresholds[1]); assertSame(threshold3, thresholds[2]); }
public static DeleterThreshold valueOf(String s) { String[] split1 = StringUtils.split(s, ']'); switch (split1.length) { case 1: return new DeleterThreshold(s, BinaryPrefix.parse(s), null); case 2: String[] split2 = StringUtils.split(split1[0], '['); if (split2.length == 2) return new DeleterThreshold(s, BinaryPrefix.parse(split1[split1.length-1]), ScheduleExpression.valueOf(split2[1])); } throw new IllegalArgumentException(s); }
DeleterThreshold extends StorageThreshold implements Comparable<DeleterThreshold> { public static DeleterThreshold valueOf(String s) { String[] split1 = StringUtils.split(s, ']'); switch (split1.length) { case 1: return new DeleterThreshold(s, BinaryPrefix.parse(s), null); case 2: String[] split2 = StringUtils.split(split1[0], '['); if (split2.length == 2) return new DeleterThreshold(s, BinaryPrefix.parse(split1[split1.length-1]), ScheduleExpression.valueOf(split2[1])); } throw new IllegalArgumentException(s); } }
DeleterThreshold extends StorageThreshold implements Comparable<DeleterThreshold> { public static DeleterThreshold valueOf(String s) { String[] split1 = StringUtils.split(s, ']'); switch (split1.length) { case 1: return new DeleterThreshold(s, BinaryPrefix.parse(s), null); case 2: String[] split2 = StringUtils.split(split1[0], '['); if (split2.length == 2) return new DeleterThreshold(s, BinaryPrefix.parse(split1[split1.length-1]), ScheduleExpression.valueOf(split2[1])); } throw new IllegalArgumentException(s); } DeleterThreshold(String value, long minUsableSpace, ScheduleExpression schedule); }
DeleterThreshold extends StorageThreshold implements Comparable<DeleterThreshold> { public static DeleterThreshold valueOf(String s) { String[] split1 = StringUtils.split(s, ']'); switch (split1.length) { case 1: return new DeleterThreshold(s, BinaryPrefix.parse(s), null); case 2: String[] split2 = StringUtils.split(split1[0], '['); if (split2.length == 2) return new DeleterThreshold(s, BinaryPrefix.parse(split1[split1.length-1]), ScheduleExpression.valueOf(split2[1])); } throw new IllegalArgumentException(s); } DeleterThreshold(String value, long minUsableSpace, ScheduleExpression schedule); static DeleterThreshold valueOf(String s); String getPrefix(); boolean match(Calendar cal); @Override int compareTo(DeleterThreshold o); }
DeleterThreshold extends StorageThreshold implements Comparable<DeleterThreshold> { public static DeleterThreshold valueOf(String s) { String[] split1 = StringUtils.split(s, ']'); switch (split1.length) { case 1: return new DeleterThreshold(s, BinaryPrefix.parse(s), null); case 2: String[] split2 = StringUtils.split(split1[0], '['); if (split2.length == 2) return new DeleterThreshold(s, BinaryPrefix.parse(split1[split1.length-1]), ScheduleExpression.valueOf(split2[1])); } throw new IllegalArgumentException(s); } DeleterThreshold(String value, long minUsableSpace, ScheduleExpression schedule); static DeleterThreshold valueOf(String s); String getPrefix(); boolean match(Calendar cal); @Override int compareTo(DeleterThreshold o);  }