Skip to content

Commit 4fbc6ea

Browse files
committed
use safe casts in StandardConverters
1 parent 6ec67a6 commit 4fbc6ea

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

hibernate-core/src/main/java/org/hibernate/engine/config/spi/StandardConverters.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77

88

9+
import static java.lang.Boolean.parseBoolean;
10+
import static java.lang.Integer.parseInt;
911
import static org.hibernate.engine.config.spi.ConfigurationService.Converter;
1012

1113
/**
@@ -17,9 +19,9 @@ public class StandardConverters {
1719
public static final Converter<Boolean> BOOLEAN = StandardConverters::asBoolean;
1820

1921
public static Boolean asBoolean(Object value) {
20-
return value instanceof Boolean
21-
? (Boolean) value
22-
: Boolean.parseBoolean( value.toString() );
22+
return value instanceof Boolean bool
23+
? bool
24+
: parseBoolean( value.toString() );
2325
}
2426

2527
public static final Converter<String> STRING = StandardConverters::asString;
@@ -31,11 +33,9 @@ public static String asString(Object value) {
3133
public static final Converter<Integer> INTEGER = StandardConverters::asInteger;
3234

3335
public static Integer asInteger(Object value) {
34-
if ( value instanceof Number ) {
35-
return ( (Number) value ).intValue();
36-
}
37-
38-
return Integer.parseInt( value.toString() );
36+
return value instanceof Number number
37+
? number.intValue()
38+
: parseInt( value.toString() );
3939
}
4040

4141
/**

0 commit comments

Comments
 (0)