FeatureRange extends PredicateValue { public static FeatureRange buildFromMixedIn(String key, List<String> partitions, int arity) { Long fromInclusive = null; Long toInclusive = null; long from = 0; long to = 0; for (String p : partitions) { String[] parts = p.split(","); if (parts.length == 1) { String[] subparts = parts[0].split("=|-"); int offset = subparts.length == 3? 0 : 1; if (subparts.length < 3 || subparts.length > 4) { throw new IllegalArgumentException("MIXED_IN range partition must be on the form label=val-val"); } from = Long.parseLong(subparts[offset + 1]); to = Long.parseLong(subparts[offset + 2]); if (parts[0].contains("=-")) { long tmp = from; from = -to; to = -tmp; } } else { if (parts.length != 3) { throw new IllegalArgumentException("MIXED_IN range edge partition must be on the form label=val,val,payload"); } long value = Long.parseLong(parts[1]); long payload = Long.parseLong(parts[2]); if ((payload & 0xc0000000) == 0x80000000L) { from = value + (payload & 0xffff); to = value + arity - 1; } else if ((payload & 0xc0000000) == 0x40000000L) { from = value; to = value + (payload & 0xffff); } else { from = value + (payload >> 16); to = value + (payload & 0xffff); } } if (fromInclusive == null || fromInclusive > from) { fromInclusive = from; } if (toInclusive == null || toInclusive > to) { toInclusive = to; } } return new FeatureRange(key, fromInclusive, toInclusive); } FeatureRange(String key);  FeatureRange(String key, Long fromInclusive, Long toInclusive); FeatureRange setKey(String key); String getKey(); FeatureRange setFromInclusive(Long from); Long getFromInclusive(); FeatureRange setToInclusive(Long to); Long getToInclusive(); void addPartition(RangePartition p); List<RangeEdgePartition> getEdgePartitions(); List<RangePartition> getPartitions(); void clearPartitions(); @Override FeatureRange clone(); @Override int hashCode(); @Override boolean equals(Object obj); static FeatureRange buildFromMixedIn(String key, List<String> partitions, int arity);  }
@Test public void requireThatFeatureRangeCanBeBuiltFromMixedInNode() { assertEquals(new FeatureRange("foo", 10L, 19L), FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=10-19"), 10)); assertEquals(new FeatureRange("foo", -19L, -10L), FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=-10-19"), 10)); assertEquals(new FeatureRange("foo", 10L, 19L), FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=10,10,9"), 10)); assertEquals(new FeatureRange("foo", 10L, 19L), FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=10,10,1073741833"), 10)); assertEquals(new FeatureRange("foo", 10L, 19L), FeatureRange.buildFromMixedIn("foo", Arrays.asList("foo=10,10,2147483648"), 10)); }