HHH-16482 - Convert Functions in StandardConverters to static methods that can be used as method references
(cherry picked from commit d7c5db47f6
)
This commit is contained in:
parent
f5be9556d7
commit
9db89979bf
|
@ -15,7 +15,9 @@ import static org.hibernate.engine.config.spi.ConfigurationService.Converter;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class StandardConverters {
|
||||
public static final Converter<Boolean> BOOLEAN = (value) -> {
|
||||
public static final Converter<Boolean> BOOLEAN = StandardConverters::asBoolean;
|
||||
|
||||
public static Boolean asBoolean(Object value) {
|
||||
if ( value == null ) {
|
||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||
}
|
||||
|
@ -23,17 +25,21 @@ public class StandardConverters {
|
|||
return value instanceof Boolean
|
||||
? (Boolean) value
|
||||
: Boolean.parseBoolean( value.toString() );
|
||||
};
|
||||
}
|
||||
|
||||
public static final Converter<String> STRING = (value) -> {
|
||||
public static final Converter<String> STRING = StandardConverters::asString;
|
||||
|
||||
public static String asString(Object value) {
|
||||
if ( value == null ) {
|
||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
};
|
||||
}
|
||||
|
||||
public static final Converter<Integer> INTEGER = (value) -> {
|
||||
public static final Converter<Integer> INTEGER = StandardConverters::asInteger;
|
||||
|
||||
public static Integer asInteger(Object value) {
|
||||
if ( value == null ) {
|
||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||
}
|
||||
|
@ -43,7 +49,7 @@ public class StandardConverters {
|
|||
}
|
||||
|
||||
return Integer.parseInt( value.toString() );
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Disallow direct instantiation
|
||||
|
|
Loading…
Reference in New Issue