NumericConstraints { public static <N extends Number> PropertyConstraint<N> positive() { return ConstraintFactory.fromPredicate( new Predicate<N>() { @Override public boolean test(N t) { return t.intValue() > 0; } }, "Should be positive" ); } private  NumericConstraints(); static PropertyConstraint<N> inRange(final N minInclusive, final N maxInclusive); static PropertyConstraint<N> positive();  }
@Test public void testPositive() { PropertyConstraint<Number> constraint = NumericConstraints.positive(); Assert.assertTrue(constraint.test(1)); Assert.assertTrue(constraint.test(1.5f)); Assert.assertTrue(constraint.test(1.5d)); Assert.assertTrue(constraint.test(100)); Assert.assertFalse(constraint.test(0)); Assert.assertFalse(constraint.test(0.1f)); Assert.assertFalse(constraint.test(0.9d)); Assert.assertFalse(constraint.test(-1)); Assert.assertFalse(constraint.test(-100)); Assert.assertFalse(constraint.test(-0.1f)); Assert.assertFalse(constraint.test(-0.1d)); }