@Test public void boundedWithin() { assertTrue(ValidationUtils.boundedWithin(0.0, 10.0, 5.0, 0.0)); assertFalse(ValidationUtils.boundedWithin(0.0, 10.0, -5.0, 0.0)); assertFalse(ValidationUtils.boundedWithin(0.0, 10.0, 15.0, 0.0)); assertFalse(ValidationUtils.boundedWithin(0.0, 10.0, Double.NaN, 0.0)); assertFalse(ValidationUtils.boundedWithin(Double.NaN, Double.NaN, 5.0, 0.0)); assertTrue(ValidationUtils.boundedWithin(Double.NaN, 10.0, 5.0, 0.0)); assertFalse(ValidationUtils.boundedWithin(Double.NaN, 10.0, 15.0, 0.0)); assertTrue(ValidationUtils.boundedWithin(0.0, Double.NaN, 5.0, 0.0)); assertFalse(ValidationUtils.boundedWithin(0.0, Double.NaN, -5.0, 0.0)); }
public static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin) { if (Double.isNaN(value) || (Double.isNaN(lowerBound) && Double.isNaN(upperBound))) { return false; } if (Double.isNaN(lowerBound)) { return value - margin <= upperBound; } if (Double.isNaN(upperBound)) { return value + margin >= lowerBound; } return value + margin >= lowerBound && value - margin <= upperBound; }
ValidationUtils { public static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin) { if (Double.isNaN(value) || (Double.isNaN(lowerBound) && Double.isNaN(upperBound))) { return false; } if (Double.isNaN(lowerBound)) { return value - margin <= upperBound; } if (Double.isNaN(upperBound)) { return value + margin >= lowerBound; } return value + margin >= lowerBound && value - margin <= upperBound; } }
ValidationUtils { public static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin) { if (Double.isNaN(value) || (Double.isNaN(lowerBound) && Double.isNaN(upperBound))) { return false; } if (Double.isNaN(lowerBound)) { return value - margin <= upperBound; } if (Double.isNaN(upperBound)) { return value + margin >= lowerBound; } return value + margin >= lowerBound && value - margin <= upperBound; } private  ValidationUtils(); }
ValidationUtils { public static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin) { if (Double.isNaN(value) || (Double.isNaN(lowerBound) && Double.isNaN(upperBound))) { return false; } if (Double.isNaN(lowerBound)) { return value - margin <= upperBound; } if (Double.isNaN(upperBound)) { return value + margin >= lowerBound; } return value + margin >= lowerBound && value - margin <= upperBound; } private  ValidationUtils(); static ValidationWriter createValidationWriter(String id, ValidationConfig config, Writer writer, ValidationType validationType); static boolean areNaN(ValidationConfig config, float... values); static boolean areNaN(ValidationConfig config, double... values); static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin); static boolean isMainComponent(ValidationConfig config, boolean mainComponent); }
ValidationUtils { public static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin) { if (Double.isNaN(value) || (Double.isNaN(lowerBound) && Double.isNaN(upperBound))) { return false; } if (Double.isNaN(lowerBound)) { return value - margin <= upperBound; } if (Double.isNaN(upperBound)) { return value + margin >= lowerBound; } return value + margin >= lowerBound && value - margin <= upperBound; } private  ValidationUtils(); static ValidationWriter createValidationWriter(String id, ValidationConfig config, Writer writer, ValidationType validationType); static boolean areNaN(ValidationConfig config, float... values); static boolean areNaN(ValidationConfig config, double... values); static boolean boundedWithin(double lowerBound, double upperBound, double value, double margin); static boolean isMainComponent(ValidationConfig config, boolean mainComponent); static final String VALIDATION_ERROR; static final String VALIDATION_WARNING; }