Commit a087878c authored by Alexander Diewald's avatar Alexander Diewald

Math: Add predicate to identify float objects

Issue-Ref: 3365
Issue-Url: https://af3-developer.fortiss.org/issues/3365Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 270f598a
AngleUtils.java 462551eae71738ff51f92c9906bff9a21a375d2b GREEN
AnnotationUtils.java 197ceb5f39af6b96eb8f7025e3fe3b1b39c35d42 GREEN
BaseMathUtils.java 65f6c39b641cba3c984a38f42b1bbf7dbf3287a3 GREEN
BaseMathUtils.java 8d26339a4410b59e6106fbaa47064b42fcc1f98a YELLOW
BaseModelElementUtils.java b8775b7a462efc168cf79a017aa3377a782d10f6 GREEN
DimensionUtils.java 0dc67f9de11a84e6e4c6e1eb627817dee91ff30a GREEN
EllipseLayoutUtils.java 5c3a0126fdca5d5b4fb441694747e1cb0f49cd9f GREEN
......
......@@ -194,18 +194,59 @@ 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 != 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 instanceof Byte || value instanceof Short || value instanceof Integer ||
value instanceof Long || value instanceof BigInteger);
}
/**
* 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);
}
/**
* Creates an {@link ArithmeticException} if an over-/underflow occurs when converting the given
* {@code number} to the given {@code targetType}.
......
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