Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Compare final boxed/primitive types with equality #5731

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Util/src/main/java/io/deephaven/util/type/TypeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ public static String nullConstantForType(Class<?> type) {
* @return true if {@code c} is a numeric primitive, false otherwise
*/
public static boolean isPrimitiveNumeric(@NotNull final Class<?> c) {
return c.equals(double.class) || c.equals(float.class)
|| c.equals(int.class) || c.equals(long.class) || c.equals(short.class) || c.equals(byte.class);
return c == double.class || c == float.class
|| c == int.class || c == long.class || c == short.class || c == byte.class;
}

/**
Expand All @@ -400,7 +400,7 @@ public static boolean isBoxedNumeric(@NotNull final Class<?> c) {
* @return true if {@code c} equals char.class, false otherwise
*/
public static boolean isPrimitiveChar(@NotNull final Class<?> c) {
return c.equals(char.class);
return c == char.class;
}

/**
Expand All @@ -410,7 +410,7 @@ public static boolean isPrimitiveChar(@NotNull final Class<?> c) {
* @return true if Character.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedChar(@NotNull final Class<?> c) {
return Character.class.isAssignableFrom(c);
return Character.class == c;
}

/**
Expand All @@ -420,7 +420,7 @@ public static boolean isBoxedChar(@NotNull final Class<?> c) {
* @return true if Integer.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedInteger(@NotNull final Class<?> c) {
return Integer.class.isAssignableFrom(c);
return Integer.class == c;
}

/**
Expand All @@ -430,7 +430,7 @@ public static boolean isBoxedInteger(@NotNull final Class<?> c) {
* @return true if Long.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedLong(@NotNull final Class<?> c) {
return Long.class.isAssignableFrom(c);
return Long.class == c;
}

/**
Expand All @@ -440,7 +440,7 @@ public static boolean isBoxedLong(@NotNull final Class<?> c) {
* @return true if Short.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedShort(@NotNull final Class<?> c) {
return Short.class.isAssignableFrom(c);
return Short.class == c;
}

/**
Expand All @@ -450,7 +450,7 @@ public static boolean isBoxedShort(@NotNull final Class<?> c) {
* @return true if Float.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedFloat(@NotNull final Class<?> c) {
return Float.class.isAssignableFrom(c);
return Float.class == c;
}

/**
Expand All @@ -460,7 +460,7 @@ public static boolean isBoxedFloat(@NotNull final Class<?> c) {
* @return true if Double.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedDouble(@NotNull final Class<?> c) {
return Double.class.isAssignableFrom(c);
return Double.class == c;
}

/**
Expand All @@ -470,7 +470,7 @@ public static boolean isBoxedDouble(@NotNull final Class<?> c) {
* @return true if Byte.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedByte(@NotNull final Class<?> c) {
return Byte.class.isAssignableFrom(c);
return Byte.class == c;
}

/**
Expand All @@ -490,7 +490,7 @@ public static boolean isBoxedArithmetic(@NotNull final Class<?> c) {
* @return true if Boolean.class is assignable from {@code c}, false otherwise
*/
public static boolean isBoxedBoolean(@NotNull final Class<?> c) {
return Boolean.class.isAssignableFrom(c);
return Boolean.class == c;
}

/**
Expand Down Expand Up @@ -532,7 +532,7 @@ public static boolean isDateTime(Class<?> type) {
* @return true if the type is a String, false otherwise
*/
public static boolean isString(Class<?> type) {
return String.class.isAssignableFrom(type);
return String.class == type;
}

/**
Expand Down
Loading