ConfigFieldValidation { public static boolean isShortAndInRange (Object value, short min, short max) { boolean result = false; if (isInteger(value)) { Integer i = (Integer) value; result = isInRange(i, min, max); } return result; }  static boolean isSubType(Class clazz, Object value); static boolean isBoolean(Object value); static boolean isInteger(Object value); static boolean isLong(Object value); static boolean isDouble(Object value); static boolean isString(Object value); static boolean isList(Object value); static boolean isByteAndInRange(Object value, byte min, byte max); static boolean isShortAndInRange(Object value, short min, short max); static boolean isIntAndInRange(Object value, int min, int max); static boolean isLongAndInRange(Object value, long min, long max); static boolean isFloatOrDouble(Object value); static boolean isStringAndNotEmpty(Object value); static boolean isInRange(int value, int min, int max); static boolean isInRange(long value, long min, long max);  }
@Test public void testShortField () { Assert.assertTrue(ConfigFieldValidation.isShortAndInRange(0, Short.MIN_VALUE, Short.MAX_VALUE)); Assert.assertFalse(ConfigFieldValidation.isShortAndInRange(null, Short.MIN_VALUE, Short.MAX_VALUE)); Assert.assertFalse(ConfigFieldValidation.isShortAndInRange(Short.MIN_VALUE - 1, Short.MIN_VALUE, Short.MAX_VALUE)); Assert.assertFalse(ConfigFieldValidation.isShortAndInRange(Short.MAX_VALUE + 1, Short.MIN_VALUE, Short.MAX_VALUE)); }