MathUtils { public static boolean isInteger( String value ) { return value != null && INT_VALIDATOR.isValid( value ) && INT_PATTERN.matcher( value ).matches(); }  static boolean isValidDouble( Double d ); static double getFloor( double value ); static double getRounded( double value ); static Object getRoundedObject( Object value ); static double roundSignificant( double value ); static double roundToSignificantDigits( double value, int n ); static double roundFraction( double value, int n ); static int getMin( int number, int min ); static int getMax( int number, int max ); static int getWithin( int value, int min, int max ); static boolean isNumeric( String value ); static boolean isNumericLenient( String value ); static boolean isUnitInterval( String value ); static boolean isPercentage( String value ); static boolean isInteger( String value ); static boolean isPositiveInteger( String value ); static boolean isZeroOrPositiveInteger( String value ); static boolean isCoordinate( String value ); static boolean isNegativeInteger( String value ); static boolean isZero( String value ); static boolean isBool( String value ); static boolean isEqual( Double d1, Double d2 ); static boolean isEqual( double d1, double d2 ); static boolean isZero( double value ); static double zeroIfNull( Double value ); static int getRandom(); static Double getMin( double[] array ); static Double getMax( double[] array ); static Double getAverage( List<Double> values ); static Double getSum( List<Double> values ); static Double parseDouble( String value ); static Integer parseInt( String string ); static double getLowBound( double stdDev, double stdDevNo, double average ); static double getHighBound( double stdDev, double stdDevFactor, double average ); static int divideToCeil( int numerator, int denominator ); static int divideToFloor( int numerator, int denominator ); static final Double ZERO; static final String NUMERIC_REGEXP; static final String NUMERIC_LENIENT_REGEXP; }
@Test public void testIsInteger() { assertTrue( MathUtils.isInteger( "1" ) ); assertTrue( MathUtils.isInteger( "123" ) ); assertTrue( MathUtils.isInteger( "-2" ) ); assertTrue( MathUtils.isInteger( "0" ) ); assertFalse( MathUtils.isInteger( "1.1" ) ); assertFalse( MathUtils.isInteger( "+4" ) ); assertFalse( MathUtils.isInteger( "-0" ) ); assertFalse( MathUtils.isInteger( "Hey" ) ); assertFalse( MathUtils.isInteger( " 1" ) ); assertFalse( MathUtils.isInteger( "1 " ) ); assertFalse( MathUtils.isInteger( "1.2345" ) ); assertFalse( MathUtils.isInteger( "12147483647" ) ); }