-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposed changes to finish cleaning these types
- Loading branch information
Showing
7 changed files
with
82 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Util/src/main/java/io/deephaven/util/type/NumericTypeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.deephaven.util.type; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
public class NumericTypeUtils { | ||
private NumericTypeUtils() {} | ||
|
||
|
||
/** | ||
* Whether the class is an instance of {@link Number}. | ||
* | ||
* @param c class | ||
* @return true if Number.class is assignable from {@code c}, false otherwise | ||
*/ | ||
public static boolean isBoxedNumeric(@NotNull final Class<?> c) { | ||
return Number.class.isAssignableFrom(c); | ||
} | ||
|
||
/** | ||
* Whether the class is {@link TypeUtils#isPrimitiveNumeric(Class)} or {@link #isBoxedNumeric(Class)} | ||
* | ||
* @param c class | ||
* @return true if {@code c} is numeric, false otherwise | ||
*/ | ||
public static boolean isNumeric(@NotNull final Class<?> c) { | ||
return TypeUtils.isPrimitiveNumeric(c) || isBoxedNumeric(c); | ||
} | ||
|
||
/** | ||
* Whether the class is a {@link BigInteger} or {@link BigDecimal} | ||
* | ||
* @param type the class | ||
* @return true if the type is BigInteger or BigDecimal, false otherwise | ||
*/ | ||
public static boolean isBigNumeric(Class<?> type) { | ||
return BigInteger.class.isAssignableFrom(type) || BigDecimal.class.isAssignableFrom(type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters