use switch expressions in isWider() impls

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-10-30 10:00:13 +01:00
parent d6e85b0a44
commit 65bc730cc1
16 changed files with 88 additions and 153 deletions

View File

@ -99,20 +99,14 @@ public class BigDecimalJavaType extends AbstractClassJavaType<BigDecimal> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":
case "long":
case "java.lang.Long":
case "java.math.BigInteger":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short",
"int", "java.lang.Integer",
"long", "java.lang.Long",
"java.math.BigInteger" -> true;
default -> false;
};
}
@Override

View File

@ -97,19 +97,13 @@ public class BigIntegerJavaType extends AbstractClassJavaType<BigInteger> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":
case "long":
case "java.lang.Long":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short",
"int", "java.lang.Integer",
"long", "java.lang.Long" -> true;
default -> false;
};
}
@Override

View File

@ -130,12 +130,10 @@ public class CalendarDateJavaType extends AbstractTemporalJavaType<Calendar> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Date":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Date" -> true;
default -> false;
};
}
@Override

View File

@ -147,14 +147,10 @@ public class CalendarJavaType extends AbstractTemporalJavaType<Calendar> impleme
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.util.Date":
case "java.sql.Date":
case "java.sql.Timestamp":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.util.Date", "java.sql.Date", "java.sql.Timestamp" -> true;
default -> false;
};
}
@Override

View File

@ -132,12 +132,10 @@ public class CalendarTimeJavaType extends AbstractTemporalJavaType<Calendar> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Time":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Time" -> true;
default -> false;
};
}
@Override

View File

@ -168,14 +168,10 @@ public class DateJavaType extends AbstractTemporalJavaType<Date> implements Vers
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Date":
case "java.sql.Timestamp":
case "java.util.Calendar":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Date", "java.sql.Timestamp", "java.util.Calendar" -> true;
default -> false;
};
}
@Override

View File

@ -103,23 +103,16 @@ public class DoubleJavaType extends AbstractClassJavaType<Double> implements
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":
case "long":
case "java.lang.Long":
case "float":
case "java.lang.Float":
case "java.math.BigInteger":
case "java.math.BigDecimal":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short",
"int", "java.lang.Integer",
"long", "java.lang.Long",
"float", "java.lang.Float",
"java.math.BigInteger",
"java.math.BigDecimal" -> true;
default -> false;
};
}
@Override

View File

@ -102,21 +102,15 @@ public class FloatJavaType extends AbstractClassJavaType<Float> implements Primi
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":
case "long":
case "java.lang.Long":
case "java.math.BigInteger":
case "java.math.BigDecimal":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short",
"int", "java.lang.Integer",
"long", "java.lang.Long",
"java.math.BigInteger",
"java.math.BigDecimal" -> true;
default -> false;
};
}
@Override

View File

@ -99,15 +99,11 @@ public class IntegerJavaType extends AbstractClassJavaType<Integer>
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short" -> true;
default -> false;
};
}
@Override

View File

@ -192,15 +192,10 @@ public class JdbcTimestampJavaType extends AbstractTemporalJavaType<Date> implem
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Date":
case "java.sql.Timestamp":
case "java.util.Date":
case "java.util.Calendar":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Date", "java.sql.Timestamp", "java.util.Date", "java.util.Calendar" -> true;
default -> false;
};
}
@Override

View File

@ -166,12 +166,10 @@ public class LocalDateJavaType extends AbstractTemporalJavaType<LocalDate> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Date":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Date" -> true;
default -> false;
};
}
}

View File

@ -165,15 +165,10 @@ public class LocalDateTimeJavaType extends AbstractTemporalJavaType<LocalDateTim
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Date":
case "java.sql.Timestamp":
case "java.util.Date":
case "java.util.Calendar":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Date", "java.sql.Timestamp", "java.util.Date", "java.util.Calendar" -> true;
default -> false;
};
}
@Override

View File

@ -177,12 +177,10 @@ public class LocalTimeJavaType extends AbstractTemporalJavaType<LocalTime> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "java.sql.Time":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "java.sql.Time" -> true;
default -> false;
};
}
@Override

View File

@ -99,17 +99,12 @@ public class LongJavaType extends AbstractClassJavaType<Long>
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
case "short":
case "java.lang.Short":
case "int":
case "java.lang.Integer":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte",
"short", "java.lang.Short",
"int", "java.lang.Integer" -> true;
default -> false;
};
}
@Override

View File

@ -45,13 +45,10 @@ public class ShortJavaType extends AbstractClassJavaType<Short>
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "byte":
case "java.lang.Byte":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "byte", "java.lang.Byte" -> true;
default -> false;
};
}
@SuppressWarnings("unchecked")

View File

@ -126,15 +126,13 @@ public class StringJavaType extends AbstractClassJavaType<String> {
@Override
public boolean isWider(JavaType<?> javaType) {
switch ( javaType.getTypeName() ) {
case "char":
case "char[]":
case "java.lang.Character":
case "java.lang.Character[]":
return true;
default:
return false;
}
return switch ( javaType.getTypeName() ) {
case "char",
"char[]",
"java.lang.Character",
"java.lang.Character[]" -> true;
default -> false;
};
}
@Override