protected boolean greater(T val, T bound) { return less(bound, val); }
public static Predicate<Value> valueConstraint(int type, String constraint) { switch (type) { case PropertyType.STRING: return new StringConstraint(constraint); case PropertyType.BINARY: return new BinaryConstraint(constraint); case PropertyType.LONG: return new LongConstraint(constraint); case PropertyType.DOUBLE: return new DoubleConstraint(constraint); case PropertyType.DATE: return new DateConstraint(constraint); case PropertyType.BOOLEAN: return new BooleanConstraint(constraint); case PropertyType.NAME: return new NameConstraint(constraint); case PropertyType.PATH: return new PathConstraint(constraint); case PropertyType.REFERENCE: return new ReferenceConstraint(constraint); case PropertyType.WEAKREFERENCE: return new ReferenceConstraint(constraint); case PropertyType.URI: return new StringConstraint(constraint); case PropertyType.DECIMAL: return new DecimalConstraint(constraint); default: String msg = "Invalid property type: " + type;
T t = getValue(value); if (lowerBound != null) { if (lowerInclusive) { if (less(t, lowerBound)) { return false; if (lessOrEqual(t, lowerBound)) { return false; if (greater(t, upperBound)) { return false; if (greaterOrEqual(t, upperBound)) { return false;
protected NumericConstraint(String definition) { // format: '(<min>, <max>)', '[<min>, <max>]', '(, <max>)' etc. Pattern pattern = Pattern.compile("([\\(\\[])([^,]*),([^\\)\\]]*)([\\)\\]])"); Matcher matcher = pattern.matcher(definition); if (matcher.matches()) { try { // group 1 is lower bound inclusive/exclusive lowerInclusive = "[".equals(matcher.group(1)); // group 2 is lower, group 3 is upper bound lowerBound = getBound(matcher.group(2)); upperBound = getBound(matcher.group(3)); // group 4 is upper bound inclusive/exclusive upperInclusive = "]".equals(matcher.group(4)); } catch (NumberFormatException e) { invalid(definition); } } else { invalid(definition); } }
private static boolean meetsValueConstraints(Value value, String[] constraints) { if (constraints == null || constraints.length == 0) { return true; } // Any of the constraints must be met for (String constraint : constraints) { if (Constraints.valueConstraint(value.getType(), constraint).apply(value)) { return true; } } return false; }
public static Predicate<Value> valueConstraint(int type, String constraint) { switch (type) { case PropertyType.STRING: return new StringConstraint(constraint); case PropertyType.BINARY: return new BinaryConstraint(constraint); case PropertyType.LONG: return new LongConstraint(constraint); case PropertyType.DOUBLE: return new DoubleConstraint(constraint); case PropertyType.DATE: return new DateConstraint(constraint); case PropertyType.BOOLEAN: return new BooleanConstraint(constraint); case PropertyType.NAME: return new NameConstraint(constraint); case PropertyType.PATH: return new PathConstraint(constraint); case PropertyType.REFERENCE: return new ReferenceConstraint(constraint); case PropertyType.WEAKREFERENCE: return new ReferenceConstraint(constraint); case PropertyType.URI: return new StringConstraint(constraint); case PropertyType.DECIMAL: return new DecimalConstraint(constraint); default: String msg = "Invalid property type: " + type;
T t = getValue(value); if (lowerBound != null) { if (lowerInclusive) { if (less(t, lowerBound)) { return false; if (lessOrEqual(t, lowerBound)) { return false; if (greater(t, upperBound)) { return false; if (greaterOrEqual(t, upperBound)) { return false;
protected NumericConstraint(String definition) { // format: '(<min>, <max>)', '[<min>, <max>]', '(, <max>)' etc. Pattern pattern = Pattern.compile("([\\(\\[])([^,]*),([^\\)\\]]*)([\\)\\]])"); Matcher matcher = pattern.matcher(definition); if (matcher.matches()) { try { // group 1 is lower bound inclusive/exclusive lowerInclusive = "[".equals(matcher.group(1)); // group 2 is lower, group 3 is upper bound lowerBound = getBound(matcher.group(2)); upperBound = getBound(matcher.group(3)); // group 4 is upper bound inclusive/exclusive upperInclusive = "]".equals(matcher.group(4)); } catch (NumberFormatException e) { invalid(definition); } } else { invalid(definition); } }
protected boolean greater(T val, T bound) { return less(bound, val); }
private static boolean meetsValueConstraints(Value value, String[] constraints) { if (constraints == null || constraints.length == 0) { return true; } // Any of the constraints must be met for (String constraint : constraints) { if (Constraints.valueConstraint(value.getType(), constraint).apply(value)) { return true; } } return false; }
public static Predicate<Value> valueConstraint(int type, String constraint) { switch (type) { case PropertyType.STRING: return new StringConstraint(constraint); case PropertyType.BINARY: return new BinaryConstraint(constraint); case PropertyType.LONG: return new LongConstraint(constraint); case PropertyType.DOUBLE: return new DoubleConstraint(constraint); case PropertyType.DATE: return new DateConstraint(constraint); case PropertyType.BOOLEAN: return new BooleanConstraint(constraint); case PropertyType.NAME: return new NameConstraint(constraint); case PropertyType.PATH: return new PathConstraint(constraint); case PropertyType.REFERENCE: return new ReferenceConstraint(constraint); case PropertyType.WEAKREFERENCE: return new ReferenceConstraint(constraint); case PropertyType.URI: return new StringConstraint(constraint); case PropertyType.DECIMAL: return new DecimalConstraint(constraint); default: String msg = "Invalid property type: " + type;
protected NumericConstraint(String definition) { // format: '(<min>, <max>)', '[<min>, <max>]', '(, <max>)' etc. Pattern pattern = Pattern.compile("([\\(\\[])([^,]*),([^\\)\\]]*)([\\)\\]])"); Matcher matcher = pattern.matcher(definition); if (matcher.matches()) { try { // group 1 is lower bound inclusive/exclusive lowerInclusive = "[".equals(matcher.group(1)); // group 2 is lower, group 3 is upper bound lowerBound = getBound(matcher.group(2)); upperBound = getBound(matcher.group(3)); // group 4 is upper bound inclusive/exclusive upperInclusive = "]".equals(matcher.group(4)); } catch (NumberFormatException e) { invalid(definition); } } else { invalid(definition); } }
protected boolean greater(T val, T bound) { return less(bound, val); }
private static boolean meetsValueConstraints(Value value, String[] constraints) { if (constraints == null || constraints.length == 0) { return true; } // Any of the constraints must be met for (String constraint : constraints) { if (Constraints.valueConstraint(value.getType(), constraint).apply(value)) { return true; } } return false; }