Skip to content

Commit 5adca84

Browse files
committed
use switch expressions
Signed-off-by: Gavin King <[email protected]>
1 parent 5827a4f commit 5adca84

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,17 @@ public interface ClassLoaderService extends ResourceLocator, ResourceStreamLocat
3535

3636
@SuppressWarnings("unchecked")
3737
default <T> Class<T> classForTypeName(String className) {
38-
switch ( className ) {
39-
case "boolean":
40-
return (Class<T>) boolean.class;
41-
case "byte":
42-
return (Class<T>) byte.class;
43-
case "char":
44-
return (Class<T>) char.class;
45-
case "short":
46-
return (Class<T>) short.class;
47-
case "int":
48-
return (Class<T>) int.class;
49-
case "float":
50-
return (Class<T>) float.class;
51-
case "long":
52-
return (Class<T>) long.class;
53-
case "double":
54-
return (Class<T>) double.class;
55-
default:
56-
return classForName( className );
57-
}
38+
return (Class<T>) switch ( className ) {
39+
case "boolean" -> boolean.class;
40+
case "byte" -> byte.class;
41+
case "char" -> char.class;
42+
case "short" -> short.class;
43+
case "int" -> int.class;
44+
case "float" -> float.class;
45+
case "long" -> long.class;
46+
case "double" -> double.class;
47+
default -> classForName( className );
48+
};
5849
}
5950

6051
/**

hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -983,19 +983,15 @@ public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
983983
public static TimeZoneStorageStrategy timeZoneStorageStrategy(
984984
TimeZoneStorageType timeZoneStorageType,
985985
MetadataBuildingContext buildingContext) {
986-
if ( timeZoneStorageType != null ) {
987-
switch ( timeZoneStorageType ) {
988-
case COLUMN:
989-
return TimeZoneStorageStrategy.COLUMN;
990-
case NATIVE:
991-
return TimeZoneStorageStrategy.NATIVE;
992-
case NORMALIZE:
993-
return TimeZoneStorageStrategy.NORMALIZE;
994-
case NORMALIZE_UTC:
995-
return TimeZoneStorageStrategy.NORMALIZE_UTC;
996-
}
997-
}
998-
return buildingContext.getBuildingOptions().getDefaultTimeZoneStorage();
986+
return timeZoneStorageType == null
987+
? buildingContext.getBuildingOptions().getDefaultTimeZoneStorage()
988+
: switch ( timeZoneStorageType ) {
989+
case COLUMN -> TimeZoneStorageStrategy.COLUMN;
990+
case NATIVE -> TimeZoneStorageStrategy.NATIVE;
991+
case NORMALIZE -> TimeZoneStorageStrategy.NORMALIZE;
992+
case NORMALIZE_UTC -> TimeZoneStorageStrategy.NORMALIZE_UTC;
993+
case AUTO, DEFAULT -> buildingContext.getBuildingOptions().getDefaultTimeZoneStorage();
994+
};
999995
}
1000996

1001997
public void setExplicitTypeParams(Map<String,String> explicitLocalTypeParams) {

0 commit comments

Comments
 (0)