Commit b9505765 authored by Alexander Diewald's avatar Alexander Diewald

Merge branch '3365' into 'master'

Math: Add predicate to identify float objects

See merge request !116
parents 270f598a 34f6a293
AngleUtils.java 462551eae71738ff51f92c9906bff9a21a375d2b GREEN
AnnotationUtils.java 197ceb5f39af6b96eb8f7025e3fe3b1b39c35d42 GREEN
BaseMathUtils.java 65f6c39b641cba3c984a38f42b1bbf7dbf3287a3 GREEN
BaseMathUtils.java 90712a1560f5b4cb9b7873a148303c970ded756d GREEN
BaseModelElementUtils.java b8775b7a462efc168cf79a017aa3377a782d10f6 GREEN
DimensionUtils.java 0dc67f9de11a84e6e4c6e1eb627817dee91ff30a GREEN
EllipseLayoutUtils.java 5c3a0126fdca5d5b4fb441694747e1cb0f49cd9f GREEN
......
......@@ -194,16 +194,56 @@ public class BaseMathUtils {
}
/**
* Predicate whether the given Number is an integer of the types Byte, Short, Integer, Long,
* BigInteger.
* Predicate whether the given Number is an integer of the types Byte, Short, Integer,
* Long, or BigInteger.
*
* @param value
* Number to test.
* @return boolean if the given Number is an integer number.
*/
public static boolean isIntegerNumber(Number value) {
return(value instanceof Byte || value instanceof Short || value instanceof Integer ||
value instanceof Long || value instanceof BigInteger);
return value != null && isIntegerNumber(value.getClass());
}
/**
* Predicate whether the given Number type is an integer of the types Byte, Short, Integer,
* Long, or BigInteger.
*
* @param valueType
* Type of the number to test.
* @return boolean if the given Number is an integer number.
*/
public static boolean isIntegerNumber(Class<?> valueType) {
return Byte.class.isAssignableFrom(valueType) || Short.class.isAssignableFrom(valueType) ||
Integer.class.isAssignableFrom(valueType) ||
Long.class.isAssignableFrom(valueType) ||
BigInteger.class.isAssignableFrom(valueType);
}
/**
* Predicate whether the given Number type is an integer of the types Float, Double, or
* BigInteger.
*
* @param value
* Number to test.
* @return boolean if the given number is an floating point number.
*/
public static boolean isFloatNumber(Number value) {
return value != null && isFloatNumber(value.getClass());
}
/**
* Predicate whether the given Number type is an integer of the types Float, Double, or
* BigInteger.
*
* @param valueType
* Type of the number to test.
* @return boolean if the given number type is an integer number.
*/
public static boolean isFloatNumber(Class<?> valueType) {
return Float.class.isAssignableFrom(valueType) ||
Double.class.isAssignableFrom(valueType) ||
BigDecimal.class.isAssignableFrom(valueType);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment