clean up a bunch of generics-related warnings

This commit is contained in:
Gavin King 2022-02-05 19:57:41 +01:00
parent 86cdf67016
commit bedd31b36e
31 changed files with 298 additions and 294 deletions

View File

@ -101,9 +101,8 @@ public abstract class AbstractConverterDescriptor implements ConverterDescriptor
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public JpaAttributeConverter createJpaAttributeConverter(JpaAttributeConverterCreationContext context) {
final JavaType<Object> converterJtd = context
public JpaAttributeConverter<?,?> createJpaAttributeConverter(JpaAttributeConverterCreationContext context) {
final JavaType<?> converterJtd = context
.getJavaTypeRegistry()
.getDescriptor( getAttributeConverterClass() );

View File

@ -45,5 +45,5 @@ public interface ConverterDescriptor {
/**
* Factory for the runtime representation of the converter
*/
JpaAttributeConverter createJpaAttributeConverter(JpaAttributeConverterCreationContext context);
JpaAttributeConverter<?,?> createJpaAttributeConverter(JpaAttributeConverterCreationContext context);
}

View File

@ -17,26 +17,26 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
/**
* @author Steve Ebersole
*/
public class InferredBasicValueResolution<J> implements BasicValue.Resolution<J> {
private JavaType<J> domainJtd;
private JavaType<J> relationalJtd;
private JdbcType jdbcType;
public class InferredBasicValueResolution<J,T> implements BasicValue.Resolution<J> {
private final JavaType<J> domainJtd;
private final JavaType<T> relationalJtd;
private final JdbcType jdbcType;
private MutabilityPlan mutabilityPlan;
private final MutabilityPlan<J> mutabilityPlan;
private JdbcMapping jdbcMapping;
private BasicValueConverter valueConverter;
private final JdbcMapping jdbcMapping;
private final BasicValueConverter<J,T> valueConverter;
private final BasicType<J> legacyType;
public InferredBasicValueResolution(
JdbcMapping jdbcMapping,
JavaType<J> domainJtd,
JavaType<J> relationalJtd,
JavaType<T> relationalJtd,
JdbcType jdbcType,
BasicValueConverter valueConverter,
BasicValueConverter<J,T> valueConverter,
BasicType<J> legacyType,
MutabilityPlan mutabilityPlan) {
MutabilityPlan<J> mutabilityPlan) {
this.jdbcMapping = jdbcMapping;
this.legacyType = legacyType;
this.domainJtd = domainJtd;
@ -52,7 +52,7 @@ public class InferredBasicValueResolution<J> implements BasicValue.Resolution<J>
}
@Override
public BasicType getLegacyResolvedBasicType() {
public BasicType<J> getLegacyResolvedBasicType() {
return legacyType;
}
@ -72,7 +72,7 @@ public class InferredBasicValueResolution<J> implements BasicValue.Resolution<J>
}
@Override
public BasicValueConverter getValueConverter() {
public BasicValueConverter<J,T> getValueConverter() {
return valueConverter;
}

View File

@ -18,7 +18,6 @@ import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Table;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.model.convert.internal.NamedEnumValueConverter;
import org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter;
import org.hibernate.type.AdjustableBasicType;
@ -45,12 +44,11 @@ public class InferredBasicValueResolver {
/**
* Create an inference-based resolution
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static BasicValue.Resolution from(
public static <T> BasicValue.Resolution<T> from(
Function<TypeConfiguration, BasicJavaType> explicitJavaTypeAccess,
Function<TypeConfiguration, JdbcType> explicitSqlTypeAccess,
Type resolvedJavaType,
Supplier<JavaType> reflectedJtdResolver,
Supplier<JavaType<T>> reflectedJtdResolver,
JdbcTypeIndicators stdIndicators,
Table table,
Selectable selectable,
@ -58,17 +56,21 @@ public class InferredBasicValueResolver {
String propertyName,
TypeConfiguration typeConfiguration) {
final BasicJavaType explicitJavaType = explicitJavaTypeAccess != null ? explicitJavaTypeAccess.apply( typeConfiguration ) : null;
final JdbcType explicitJdbcType = explicitSqlTypeAccess != null ? explicitSqlTypeAccess.apply( typeConfiguration ) : null;
final BasicJavaType<T> explicitJavaType = explicitJavaTypeAccess != null
? explicitJavaTypeAccess.apply( typeConfiguration )
: null;
final JdbcType explicitJdbcType = explicitSqlTypeAccess
!= null ? explicitSqlTypeAccess.apply( typeConfiguration )
: null;
final BasicJavaType reflectedJtd = (BasicJavaType) reflectedJtdResolver.get();
final JavaType<T> reflectedJtd = reflectedJtdResolver.get();
// NOTE : the distinction that is made below wrt `explicitJavaType` and `reflectedJtd` is
// needed temporarily to trigger "legacy resolution" versus "ORM6 resolution. Yes, it
// makes the code a little more complicated but the benefit is well worth it - saving memory
final BasicType<?> jdbcMapping;
final BasicType<?> legacyType;
final BasicType<T> jdbcMapping;
final BasicType<T> legacyType;
if ( explicitJavaType != null ) {
// we have an explicit JavaType
@ -99,7 +101,7 @@ public class InferredBasicValueResolver {
}
else if ( explicitJavaType instanceof TemporalJavaType ) {
return fromTemporal(
(TemporalJavaType) reflectedJtd,
(TemporalJavaType<T>) reflectedJtd,
explicitJavaType,
null,
resolvedJavaType,
@ -107,8 +109,9 @@ public class InferredBasicValueResolver {
typeConfiguration
);
}
else if ( explicitJavaType instanceof SerializableJavaType || explicitJavaType.getJavaType() instanceof Serializable ) {
legacyType = new SerializableType<>( explicitJavaType );
else if ( explicitJavaType instanceof SerializableJavaType
|| explicitJavaType.getJavaType() instanceof Serializable ) {
legacyType = new SerializableType( explicitJavaType );
jdbcMapping = legacyType;
}
else {
@ -154,7 +157,7 @@ public class InferredBasicValueResolver {
}
else if ( reflectedJtd instanceof TemporalJavaType ) {
return fromTemporal(
(TemporalJavaType) reflectedJtd,
(TemporalJavaType<T>) reflectedJtd,
null,
null,
resolvedJavaType,
@ -165,7 +168,8 @@ public class InferredBasicValueResolver {
else {
// see if there is a registered BasicType for this JavaType and, if so, use it.
// this mimics the legacy handling
final BasicType registeredType = typeConfiguration.getBasicTypeRegistry().getRegisteredType( reflectedJtd.getJavaType() );
final BasicType<T> registeredType = typeConfiguration.getBasicTypeRegistry()
.getRegisteredType( reflectedJtd.getJavaType() );
if ( registeredType != null ) {
// so here is the legacy resolution
@ -183,8 +187,9 @@ public class InferredBasicValueResolver {
);
legacyType = jdbcMapping;
}
else if ( reflectedJtd instanceof SerializableJavaType || Serializable.class.isAssignableFrom( reflectedJtd.getJavaTypeClass() ) ) {
legacyType = new SerializableType<>( reflectedJtd );
else if ( reflectedJtd instanceof SerializableJavaType
|| Serializable.class.isAssignableFrom( reflectedJtd.getJavaTypeClass() ) ) {
legacyType = new SerializableType( reflectedJtd );
jdbcMapping = legacyType;
}
else {
@ -217,17 +222,20 @@ public class InferredBasicValueResolver {
}
}
}
final BasicJavaType recommendedJtd = explicitJdbcType.getJdbcRecommendedJavaTypeMapping(
final BasicJavaType<T> recommendedJtd = explicitJdbcType.getJdbcRecommendedJavaTypeMapping(
length,
scale,
typeConfiguration
);
final BasicType<?> resolved = typeConfiguration.getBasicTypeRegistry().resolve(
recommendedJtd,
explicitJdbcType
);
jdbcMapping = resolveSqlTypeIndicators( stdIndicators, resolved, recommendedJtd );
jdbcMapping = resolveSqlTypeIndicators(
stdIndicators,
typeConfiguration.getBasicTypeRegistry().resolve(
recommendedJtd,
explicitJdbcType
),
recommendedJtd );
legacyType = jdbcMapping;
}
else {
@ -252,7 +260,7 @@ public class InferredBasicValueResolver {
);
}
return new InferredBasicValueResolution(
return new InferredBasicValueResolution<>(
jdbcMapping,
jdbcMapping.getJavaTypeDescriptor(),
jdbcMapping.getJavaTypeDescriptor(),
@ -263,14 +271,13 @@ public class InferredBasicValueResolver {
);
}
@SuppressWarnings("rawtypes")
public static BasicType<?> resolveSqlTypeIndicators(
public static <T> BasicType<T> resolveSqlTypeIndicators(
JdbcTypeIndicators stdIndicators,
BasicType<?> resolved,
JavaType<?> domainJtd) {
BasicType<T> resolved,
JavaType<T> domainJtd) {
if ( resolved instanceof AdjustableBasicType ) {
final AdjustableBasicType indicatorCapable = (AdjustableBasicType) resolved;
final BasicType indicatedType = indicatorCapable.resolveIndicatedType( stdIndicators, domainJtd );
final AdjustableBasicType<T> indicatorCapable = (AdjustableBasicType<T>) resolved;
final BasicType<T> indicatedType = indicatorCapable.resolveIndicatedType( stdIndicators, domainJtd );
return indicatedType != null ? indicatedType : resolved;
}
else {
@ -278,10 +285,9 @@ public class InferredBasicValueResolver {
}
}
@SuppressWarnings("rawtypes")
public static <E extends Enum<E>> InferredBasicValueResolution fromEnum(
public static <E extends Enum<E>> InferredBasicValueResolution<E,?> fromEnum(
EnumJavaType<E> enumJavaType,
BasicJavaType explicitJavaType,
BasicJavaType<?> explicitJavaType,
JdbcType explicitJdbcType,
JdbcTypeIndicators stdIndicators,
TypeConfiguration typeConfiguration) {
@ -291,101 +297,21 @@ public class InferredBasicValueResolver {
switch ( enumStyle ) {
case STRING: {
final JavaType<?> relationalJtd;
if ( explicitJavaType != null ) {
if ( ! String.class.isAssignableFrom( explicitJavaType.getJavaTypeClass() ) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] applied to enumerated value with EnumType#STRING" +
" should handle `java.lang.String` as its relational type descriptor"
);
}
relationalJtd = explicitJavaType;
}
else {
final boolean useCharacter = stdIndicators.getColumnLength() == 1;
final Class<?> relationalJavaType = useCharacter ? Character.class : String.class;
relationalJtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( relationalJavaType );
}
final JdbcType jdbcType = explicitJdbcType != null ? explicitJdbcType : relationalJtd.getRecommendedJdbcType( stdIndicators );
//noinspection unchecked
final NamedEnumValueConverter valueConverter = new NamedEnumValueConverter(
return stringEnumValueResolution(
enumJavaType,
jdbcType,
relationalJtd
);
final org.hibernate.type.EnumType<E> legacyEnumType = new org.hibernate.type.EnumType<>(
enumJavaType.getJavaTypeClass(),
valueConverter,
explicitJavaType,
explicitJdbcType,
stdIndicators,
typeConfiguration
);
final CustomType<E> legacyEnumTypeWrapper = new CustomType<>( legacyEnumType, typeConfiguration );
final JdbcMapping jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( relationalJtd, jdbcType );
//noinspection unchecked
return new InferredBasicValueResolution(
jdbcMapping,
enumJavaType,
relationalJtd,
jdbcType,
valueConverter,
legacyEnumTypeWrapper,
ImmutableMutabilityPlan.INSTANCE
);
}
case ORDINAL: {
final JavaType<Integer> relationalJtd;
if ( explicitJavaType != null ) {
if ( ! Integer.class.isAssignableFrom( explicitJavaType.getJavaTypeClass() ) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] applied to enumerated value with EnumType#ORDINAL" +
" should handle `java.lang.Integer` as its relational type descriptor"
);
}
//noinspection unchecked
relationalJtd = explicitJavaType;
}
else {
relationalJtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( Integer.class );
}
final JdbcType jdbcType = explicitJdbcType != null
? explicitJdbcType
: typeConfiguration.getJdbcTypeRegistry().getDescriptor( SqlTypes.TINYINT );
//noinspection unchecked
final OrdinalEnumValueConverter valueConverter = new OrdinalEnumValueConverter(
return ordinalEnumValueResolution(
enumJavaType,
jdbcType,
relationalJtd
);
final org.hibernate.type.EnumType<E> legacyEnumType = new org.hibernate.type.EnumType<>(
enumJavaType.getJavaTypeClass(),
valueConverter,
explicitJavaType,
explicitJdbcType,
typeConfiguration
);
final CustomType<E> legacyEnumTypeWrapper = new CustomType<>( legacyEnumType, typeConfiguration );
final JdbcMapping jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( relationalJtd, jdbcType );
//noinspection unchecked
return new InferredBasicValueResolution(
jdbcMapping,
enumJavaType,
relationalJtd,
jdbcType,
valueConverter,
legacyEnumTypeWrapper,
ImmutableMutabilityPlan.INSTANCE
);
}
default: {
throw new MappingException( "Unknown enumeration-style (JPA EnumType) : " + enumStyle );
@ -393,10 +319,110 @@ public class InferredBasicValueResolver {
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
public static InferredBasicValueResolution fromTemporal(
TemporalJavaType reflectedJtd,
BasicJavaType explicitJavaType,
private static <E extends Enum<E>> InferredBasicValueResolution<E, Integer> ordinalEnumValueResolution(
EnumJavaType<E> enumJavaType,
BasicJavaType<?> explicitJavaType,
JdbcType explicitJdbcType,
TypeConfiguration typeConfiguration) {
final JavaType<Integer> relationalJtd;
if ( explicitJavaType != null ) {
if ( ! Integer.class.isAssignableFrom( explicitJavaType.getJavaTypeClass() ) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] applied to enumerated value with EnumType#ORDINAL" +
" should handle `java.lang.Integer` as its relational type descriptor"
);
}
//noinspection unchecked
relationalJtd = (BasicJavaType<Integer>) explicitJavaType;
}
else {
relationalJtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( Integer.class );
}
final JdbcType jdbcType = explicitJdbcType != null
? explicitJdbcType
: typeConfiguration.getJdbcTypeRegistry().getDescriptor( SqlTypes.TINYINT );
final OrdinalEnumValueConverter<E> valueConverter = new OrdinalEnumValueConverter<>(
enumJavaType,
jdbcType,
relationalJtd
);
return new InferredBasicValueResolution<>(
typeConfiguration.getBasicTypeRegistry().resolve(relationalJtd, jdbcType),
enumJavaType,
relationalJtd,
jdbcType,
valueConverter,
new CustomType<>(
new org.hibernate.type.EnumType<>(
enumJavaType.getJavaTypeClass(),
valueConverter,
typeConfiguration
),
typeConfiguration
),
ImmutableMutabilityPlan.instance()
);
}
private static <E extends Enum<E>> InferredBasicValueResolution<E, String> stringEnumValueResolution(
EnumJavaType<E> enumJavaType,
BasicJavaType<?> explicitJavaType,
JdbcType explicitJdbcType,
JdbcTypeIndicators stdIndicators,
TypeConfiguration typeConfiguration) {
final JavaType<String> relationalJtd;
if ( explicitJavaType != null ) {
if ( ! String.class.isAssignableFrom( explicitJavaType.getJavaTypeClass() ) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] applied to enumerated value with EnumType#STRING" +
" should handle `java.lang.String` as its relational type descriptor"
);
}
//noinspection unchecked
relationalJtd = (BasicJavaType<String>) explicitJavaType;
}
else {
final boolean useCharacter = stdIndicators.getColumnLength() == 1;
relationalJtd = typeConfiguration.getJavaTypeRegistry()
.getDescriptor( useCharacter ? Character.class : String.class );
}
final JdbcType jdbcType = explicitJdbcType != null
? explicitJdbcType
: relationalJtd.getRecommendedJdbcType(stdIndicators);
final NamedEnumValueConverter<E> valueConverter = new NamedEnumValueConverter<>(
enumJavaType,
jdbcType,
relationalJtd
);
return new InferredBasicValueResolution<>(
typeConfiguration.getBasicTypeRegistry().resolve(relationalJtd, jdbcType),
enumJavaType,
relationalJtd,
jdbcType,
valueConverter,
new CustomType<>(
new org.hibernate.type.EnumType<>(
enumJavaType.getJavaTypeClass(),
valueConverter,
typeConfiguration
),
typeConfiguration
),
ImmutableMutabilityPlan.instance()
);
}
public static <T> InferredBasicValueResolution<T,T> fromTemporal(
TemporalJavaType<T> reflectedJtd,
BasicJavaType<?> explicitJavaType,
JdbcType explicitJdbcType,
Type resolvedJavaType,
JdbcTypeIndicators stdIndicators,
@ -407,14 +433,15 @@ public class InferredBasicValueResolver {
// Case #1 - explicit JavaType
if ( explicitJavaType != null ) {
if ( !TemporalJavaType.class.isInstance( explicitJavaType ) ) {
if ( !(explicitJavaType instanceof TemporalJavaType) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] defined for temporal value must implement TemporalJavaType"
);
}
final TemporalJavaType explicitTemporalJtd = (TemporalJavaType) explicitJavaType;
@SuppressWarnings("unchecked")
final TemporalJavaType<T> explicitTemporalJtd = (TemporalJavaType<T>) explicitJavaType;
if ( requestedTemporalPrecision != null && explicitTemporalJtd.getPrecision() != requestedTemporalPrecision ) {
throw new MappingException(
@ -424,18 +451,20 @@ public class InferredBasicValueResolver {
);
}
final JdbcType jdbcType = explicitJdbcType != null ? explicitJdbcType : explicitTemporalJtd.getRecommendedJdbcType( stdIndicators );
final JdbcType jdbcType = explicitJdbcType != null
? explicitJdbcType
: explicitTemporalJtd.getRecommendedJdbcType( stdIndicators );
final BasicType jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( explicitTemporalJtd, jdbcType );
final BasicType<T> jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( explicitTemporalJtd, jdbcType );
return new InferredBasicValueResolution(
return new InferredBasicValueResolution<>(
jdbcMapping,
explicitTemporalJtd,
explicitTemporalJtd,
jdbcType,
null,
jdbcMapping,
explicitJavaType.getMutabilityPlan()
explicitTemporalJtd.getMutabilityPlan()
);
}
@ -446,7 +475,7 @@ public class InferredBasicValueResolver {
// due to the new annotations being used
if ( explicitJdbcType != null ) {
final TemporalJavaType jtd;
final TemporalJavaType<T> jtd;
if ( requestedTemporalPrecision != null ) {
jtd = reflectedJtd.resolveTypeForPrecision(
@ -458,9 +487,9 @@ public class InferredBasicValueResolver {
jtd = reflectedJtd;
}
final BasicType jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( jtd, explicitJdbcType );
final BasicType<T> jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( jtd, explicitJdbcType );
return new InferredBasicValueResolution(
return new InferredBasicValueResolution<>(
jdbcMapping,
jtd,
jtd,
@ -476,7 +505,7 @@ public class InferredBasicValueResolver {
//
// - for the moment continue to use the legacy resolution to registered
// BasicType
final BasicType basicType;
final BasicType<T> basicType;
if ( requestedTemporalPrecision != null && requestedTemporalPrecision != reflectedJtd.getPrecision() ) {
basicType = typeConfiguration.getBasicTypeRegistry().resolve(
reflectedJtd.resolveTypeForPrecision( requestedTemporalPrecision, typeConfiguration ),
@ -490,7 +519,7 @@ public class InferredBasicValueResolver {
);
}
return new InferredBasicValueResolution(
return new InferredBasicValueResolution<>(
basicType,
basicType.getJavaTypeDescriptor(),
basicType.getJavaTypeDescriptor(),

View File

@ -32,10 +32,9 @@ import org.hibernate.type.spi.TypeConfiguration;
/**
* @author Steve Ebersole
*/
@SuppressWarnings("rawtypes")
public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
public static NamedConverterResolution from(
public static <T> NamedConverterResolution<T> from(
ConverterDescriptor converterDescriptor,
Function<TypeConfiguration, BasicJavaType> explicitJtdAccess,
Function<TypeConfiguration, JdbcType> explicitStdAccess,
@ -47,13 +46,13 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
explicitJtdAccess,
explicitStdAccess,
explicitMutabilityPlanAccess,
converterDescriptor.createJpaAttributeConverter( converterCreationContext ),
converter( converterCreationContext, converterDescriptor ),
sqlTypeIndicators,
context
);
}
public static NamedConverterResolution from(
public static <T> NamedConverterResolution<T> from(
String name,
Function<TypeConfiguration, BasicJavaType> explicitJtdAccess,
Function<TypeConfiguration, JdbcType> explicitStdAccess,
@ -64,12 +63,10 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
assert name.startsWith( ConverterDescriptor.TYPE_NAME_PREFIX );
final String converterClassName = name.substring( ConverterDescriptor.TYPE_NAME_PREFIX.length() );
final StandardServiceRegistry serviceRegistry = context.getBootstrapContext().getServiceRegistry();
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
final Class<? extends AttributeConverter> converterClass = classLoaderService.classForName( converterClassName );
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
converterClass,
context.getBootstrapContext().getServiceRegistry()
.getService( ClassLoaderService.class )
.classForName( converterClassName ),
context.getBootstrapContext().getClassmateContext()
);
@ -77,25 +74,33 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
explicitJtdAccess,
explicitStdAccess,
explicitMutabilityPlanAccess,
converterDescriptor.createJpaAttributeConverter( converterCreationContext ),
converter( converterCreationContext, converterDescriptor ),
sqlTypeIndicators,
context
);
}
private static NamedConverterResolution fromInternal(
private static <T> JpaAttributeConverter<T, ?> converter(
JpaAttributeConverterCreationContext converterCreationContext,
ConverterDescriptor converterDescriptor) {
//noinspection unchecked
return (JpaAttributeConverter<T,?>) converterDescriptor.createJpaAttributeConverter(converterCreationContext);
}
private static <T> NamedConverterResolution<T> fromInternal(
Function<TypeConfiguration, BasicJavaType> explicitJtdAccess,
Function<TypeConfiguration, JdbcType> explicitStdAccess,
Function<TypeConfiguration, MutabilityPlan> explicitMutabilityPlanAccess,
JpaAttributeConverter converter, JdbcTypeIndicators sqlTypeIndicators,
JpaAttributeConverter<T,?> converter,
JdbcTypeIndicators sqlTypeIndicators,
MetadataBuildingContext context) {
final TypeConfiguration typeConfiguration = context.getBootstrapContext().getTypeConfiguration();
final JavaType explicitJtd = explicitJtdAccess != null
final JavaType<T> explicitJtd = explicitJtdAccess != null
? explicitJtdAccess.apply( typeConfiguration )
: null;
final JavaType domainJtd = explicitJtd != null
final JavaType<T> domainJtd = explicitJtd != null
? explicitJtd
: converter.getDomainJavaType();
@ -103,29 +108,29 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
? explicitStdAccess.apply( typeConfiguration )
: null;
final JavaType relationalJtd = converter.getRelationalJavaType();
final JavaType<?> relationalJtd = converter.getRelationalJavaType();
final JdbcType jdbcType = explicitJdbcType != null
? explicitJdbcType
: relationalJtd.getRecommendedJdbcType( sqlTypeIndicators );
final MutabilityPlan explicitMutabilityPlan = explicitMutabilityPlanAccess != null
final MutabilityPlan<T> explicitMutabilityPlan = explicitMutabilityPlanAccess != null
? explicitMutabilityPlanAccess.apply( typeConfiguration )
: null;
final MutabilityPlan mutabilityPlan;
final MutabilityPlan<T> mutabilityPlan;
if ( explicitMutabilityPlan != null ) {
mutabilityPlan = explicitMutabilityPlan;
}
else if ( ! domainJtd.getMutabilityPlan().isMutable() ) {
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
mutabilityPlan = ImmutableMutabilityPlan.instance();
}
else {
mutabilityPlan = new AttributeConverterMutabilityPlanImpl( converter, true );
mutabilityPlan = new AttributeConverterMutabilityPlanImpl<>( converter, true );
}
return new NamedConverterResolution(
return new NamedConverterResolution<T>(
domainJtd,
relationalJtd,
jdbcType,
@ -136,24 +141,23 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
}
private final JavaType domainJtd;
private final JavaType relationalJtd;
private final JavaType<J> domainJtd;
private final JavaType<?> relationalJtd;
private final JdbcType jdbcType;
private final JpaAttributeConverter valueConverter;
private final MutabilityPlan mutabilityPlan;
private final JpaAttributeConverter<J,?> valueConverter;
private final MutabilityPlan<J> mutabilityPlan;
private final JdbcMapping jdbcMapping;
private final BasicType legacyResolvedType;
private final BasicType<J> legacyResolvedType;
@SuppressWarnings("unchecked")
public NamedConverterResolution(
JavaType domainJtd,
JavaType relationalJtd,
JavaType<J> domainJtd,
JavaType<?> relationalJtd,
JdbcType jdbcType,
JpaAttributeConverter valueConverter,
MutabilityPlan mutabilityPlan,
JpaAttributeConverter<J,?> valueConverter,
MutabilityPlan<J> mutabilityPlan,
TypeConfiguration typeConfiguration) {
assert domainJtd != null;
this.domainJtd = domainJtd;
@ -208,8 +212,9 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
// typeConfiguration
// );
this.legacyResolvedType = new AttributeConverterTypeAdapter(
ConverterDescriptor.TYPE_NAME_PREFIX + valueConverter.getConverterJavaType().getJavaType().getTypeName(),
this.legacyResolvedType = new AttributeConverterTypeAdapter<>(
ConverterDescriptor.TYPE_NAME_PREFIX
+ valueConverter.getConverterJavaType().getJavaType().getTypeName(),
String.format(
"BasicType adapter for AttributeConverter<%s,%s>",
domainJtd.getJavaType().getTypeName(),
@ -225,13 +230,11 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
@Override
public BasicType<J> getLegacyResolvedBasicType() {
//noinspection unchecked
return legacyResolvedType;
}
@Override
public JavaType<J> getDomainJavaType() {
//noinspection unchecked
return domainJtd;
}
@ -251,13 +254,12 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
}
@Override
public JpaAttributeConverter getValueConverter() {
public JpaAttributeConverter<J,?> getValueConverter() {
return valueConverter;
}
@Override
public MutabilityPlan<J> getMutabilityPlan() {
//noinspection unchecked
return mutabilityPlan;
}

View File

@ -756,8 +756,11 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
// envers - grr
setTypeParameters( properties );
final CustomType<Object> customType = new CustomType<>( (UserType<Object>) typeInstance, typeConfiguration );
this.resolution = new UserTypeResolution( customType, null, properties );
this.resolution = new UserTypeResolution(
new CustomType<>( (UserType<Object>) typeInstance, typeConfiguration ),
null,
properties
);
}
}
@ -817,7 +820,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
* Converter, if any, to convert values between the
* domain and relational JavaType representations
*/
BasicValueConverter getValueConverter();
BasicValueConverter<J,?> getValueConverter();
/**
* The resolved MutabilityPlan

View File

@ -52,7 +52,7 @@ import org.hibernate.type.Type;
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
import org.hibernate.type.descriptor.converter.AttributeConverterJdbcTypeAdapter;
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
import org.hibernate.type.descriptor.java.BasicJavaType;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.descriptor.jdbc.LobTypeMappings;
@ -728,8 +728,7 @@ public abstract class SimpleValue implements KeyValue {
*/
private Type buildAttributeConverterTypeAdapter() {
// todo : validate the number of columns present here?
final JpaAttributeConverter jpaAttributeConverter = attributeConverterDescriptor.createJpaAttributeConverter(
return buildAttributeConverterTypeAdapter( attributeConverterDescriptor.createJpaAttributeConverter(
new JpaAttributeConverterCreationContext() {
@Override
public ManagedBeanRegistry getManagedBeanRegistry() {
@ -744,9 +743,13 @@ public abstract class SimpleValue implements KeyValue {
return getMetadata().getTypeConfiguration();
}
}
);
) );
}
final BasicJavaType<?> domainJtd = (BasicJavaType<?>) jpaAttributeConverter.getDomainJavaType();
private <T> AttributeConverterTypeAdapter<T> buildAttributeConverterTypeAdapter(
JpaAttributeConverter<T, ?> jpaAttributeConverter) {
JavaType<T> domainJavaType = jpaAttributeConverter.getDomainJavaType();
JavaType<?> relationalJavaType = jpaAttributeConverter.getRelationalJavaType();
// build the SqlTypeDescriptor adapter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Going back to the illustration, this should be a SqlTypeDescriptor that handles the Integer <-> String
@ -754,7 +757,7 @@ public abstract class SimpleValue implements KeyValue {
// corresponding to the AttributeConverter's declared "databaseColumnJavaType" (how we read that value out
// of ResultSets). See JdbcTypeJavaClassMappings for details. Again, given example, this should return
// VARCHAR/CHAR
final JdbcType recommendedJdbcType = jpaAttributeConverter.getRelationalJavaType().getRecommendedJdbcType(
final JdbcType recommendedJdbcType = relationalJavaType.getRecommendedJdbcType(
// todo (6.0) : handle the other JdbcRecommendedSqlTypeMappingContext methods
new JdbcTypeIndicators() {
@Override
@ -774,7 +777,7 @@ public abstract class SimpleValue implements KeyValue {
jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode );
}
else {
if ( Serializable.class.isAssignableFrom( domainJtd.getJavaTypeClass() ) ) {
if ( Serializable.class.isAssignableFrom( domainJavaType.getJavaTypeClass() ) ) {
jdbcTypeCode = Types.BLOB;
}
else {
@ -793,33 +796,26 @@ public abstract class SimpleValue implements KeyValue {
jdbcTypeCode = NationalizedTypeMappings.toNationalizedTypeCode( jdbcTypeCode );
}
final JdbcType jdbcType = metadata.getTypeConfiguration()
.getJdbcTypeRegistry()
.getDescriptor( jdbcTypeCode );
// and finally construct the adapter, which injects the AttributeConverter calls into the binding/extraction
// process...
final JdbcType jdbcTypeAdapter = new AttributeConverterJdbcTypeAdapter(
jpaAttributeConverter,
jdbcType,
jpaAttributeConverter.getRelationalJavaType()
);
// todo : cache the AttributeConverterTypeAdapter in case that AttributeConverter is applied multiple times.
final String name = ConverterDescriptor.TYPE_NAME_PREFIX + jpaAttributeConverter.getConverterJavaType().getJavaType().getTypeName();
final String description = String.format(
"BasicType adapter for AttributeConverter<%s,%s>",
jpaAttributeConverter.getDomainJavaType().getJavaType().getTypeName(),
jpaAttributeConverter.getRelationalJavaType().getJavaType().getTypeName()
);
return new AttributeConverterTypeAdapter<>(
name,
description,
ConverterDescriptor.TYPE_NAME_PREFIX
+ jpaAttributeConverter.getConverterJavaType().getJavaType().getTypeName(),
String.format(
"BasicType adapter for AttributeConverter<%s,%s>",
domainJavaType.getJavaType().getTypeName(),
relationalJavaType.getJavaType().getTypeName()
),
jpaAttributeConverter,
jdbcTypeAdapter,
jpaAttributeConverter.getRelationalJavaType(),
jpaAttributeConverter.getDomainJavaType(),
// and finally construct the adapter, which injects the AttributeConverter
// calls into the binding/extraction process...
new AttributeConverterJdbcTypeAdapter(
jpaAttributeConverter,
metadata.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode ),
relationalJavaType
),
relationalJavaType,
domainJavaType,
null
);
}

View File

@ -215,7 +215,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
final MutabilityPlan<?> mutabilityPlan;
if ( updateable ) {
mutabilityPlan = new MutabilityPlan<Object>() {
mutabilityPlan = new MutabilityPlan<>() {
@Override
public boolean isMutable() {
return true;

View File

@ -184,7 +184,7 @@ public class MappingModelCreationHelper {
final Value value = bootProperty.getValue();
final BasicValue.Resolution<?> resolution = ( (Resolvable) value ).resolve();
final BasicValueConverter valueConverter = resolution.getValueConverter();
final BasicValueConverter<?,?> valueConverter = resolution.getValueConverter();
final StateArrayContributorMetadataAccess attributeMetadataAccess = entityMappingType -> new StateArrayContributorMetadata() {
private final MutabilityPlan mutabilityPlan = resolution.getMutabilityPlan();
@ -258,7 +258,6 @@ public class MappingModelCreationHelper {
// we want to "decompose" the "type" into its various pieces as expected by the mapping
assert valueConverter.getRelationalJavaType() == resolution.getRelationalJavaType();
//noinspection unchecked
final BasicType<?> mappingBasicType = creationProcess.getCreationContext()
.getDomainModel()
.getTypeConfiguration()

View File

@ -4000,10 +4000,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
}
else {
final MappingModelExpressible<?> elementExpressible = getElementExpressible( localExpressible );
if ( elementExpressible instanceof BasicType<?> ) {
if ( elementExpressible instanceof BasicType ) {
expressible = InferredBasicValueResolver.resolveSqlTypeIndicators(
this,
(BasicType<?>) elementExpressible,
(BasicType) elementExpressible,
literal.getJavaTypeDescriptor()
);
}
@ -4080,21 +4080,16 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
}
}
else {
if ( literal instanceof SqmLiteral ) {
return new QueryLiteral<>(
literal.getLiteralValue(),
creationContext.getSessionFactory()
.getTypeConfiguration()
.getBasicTypeRegistry()
.getRegisteredType(
( (BasicSqmPathSource) literal.getNodeType() ).getSqmPathType()
.getJavaType()
.getName()
)
);
}
throw new NotYetImplementedFor6Exception(
expressible == null ? literal.getLiteralValue().getClass() : expressible.getClass()
return new QueryLiteral<>(
literal.getLiteralValue(),
creationContext.getSessionFactory()
.getTypeConfiguration()
.getBasicTypeRegistry()
.getRegisteredType(
( (BasicSqmPathSource<?>) literal.getNodeType() ).getSqmPathType()
.getJavaType()
.getName()
)
);
}
}
@ -4613,10 +4608,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
@Override
public Object visitCastTarget(SqmCastTarget<?> target) {
BasicValuedMapping targetType = (BasicValuedMapping) target.getType();
if ( targetType instanceof BasicType<?> ) {
if ( targetType instanceof BasicType ) {
targetType = InferredBasicValueResolver.resolveSqlTypeIndicators(
this,
(BasicType<?>) targetType,
(BasicType) targetType,
target.getNodeJavaType()
);
}
@ -5320,7 +5315,6 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
final BasicValuedMapping inferrableType = (BasicValuedMapping) resolveInferredType();
if ( inferrableType instanceof ConvertibleModelPart ) {
final ConvertibleModelPart inferredPart = (ConvertibleModelPart) inferrableType;
@SuppressWarnings("unchecked")
final BasicValueConverter<Enum<?>,?> valueConverter = inferredPart.getValueConverter();
final Object jdbcValue = valueConverter.toRelationalValue( sqmEnumLiteral.getEnumValue() );
return new QueryLiteral<>( jdbcValue, inferredPart );
@ -5335,7 +5329,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
return new ConvertedQueryLiteral(
sqmEnumLiteral.getEnumValue(),
new OrdinalEnumValueConverter( enumJtd, jdbcType, relationalJtd ),
new OrdinalEnumValueConverter<>( enumJtd, jdbcType, relationalJtd ),
jdbcMappingType
);
}

View File

@ -35,9 +35,8 @@ public abstract class AbstractClassJavaType<T> implements BasicJavaType<T>, Seri
*
* @see #AbstractClassJavaType(Class, MutabilityPlan)
*/
@SuppressWarnings({ "unchecked" })
protected AbstractClassJavaType(Class<? extends T> type) {
this( type, (MutabilityPlan<T>) ImmutableMutabilityPlan.INSTANCE );
this( type, ImmutableMutabilityPlan.instance() );
}
/**

View File

@ -36,9 +36,8 @@ public abstract class AbstractJavaType<T> implements BasicJavaType<T>, Serializa
*
* @see #AbstractJavaType(Type, MutabilityPlan)
*/
@SuppressWarnings({ "unchecked" })
protected AbstractJavaType(Type type) {
this( type, (MutabilityPlan<T>) ImmutableMutabilityPlan.INSTANCE );
this( type, ImmutableMutabilityPlan.instance() );
}
/**
@ -47,7 +46,7 @@ public abstract class AbstractJavaType<T> implements BasicJavaType<T>, Serializa
* @param type The Java type.
* @param mutabilityPlan The plan for handling mutability aspects of the java type.
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings("unchecked")
protected AbstractJavaType(Type type, MutabilityPlan<T> mutabilityPlan) {
this.type = type;
this.mutabilityPlan = mutabilityPlan;
@ -86,13 +85,13 @@ public abstract class AbstractJavaType<T> implements BasicJavaType<T>, Serializa
return (value == null) ? "null" : value.toString();
}
protected HibernateException unknownUnwrap(Class conversionType) {
protected HibernateException unknownUnwrap(Class<?> conversionType) {
throw new HibernateException(
"Unknown unwrap conversion requested: " + type.getTypeName() + " to " + conversionType.getName()
);
}
protected HibernateException unknownWrap(Class conversionType) {
protected HibernateException unknownWrap(Class<?> conversionType) {
throw new HibernateException(
"Unknown wrap conversion requested: " + conversionType.getName() + " to " + type.getTypeName()
);

View File

@ -38,9 +38,8 @@ public class DurationJavaType extends AbstractClassJavaType<Duration> {
*/
public static final DurationJavaType INSTANCE = new DurationJavaType();
@SuppressWarnings("unchecked")
public DurationJavaType() {
super( Duration.class, ImmutableMutabilityPlan.INSTANCE );
super( Duration.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -21,9 +21,8 @@ import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
* @author Steve Ebersole
*/
public class EnumJavaType<T extends Enum<T>> extends AbstractClassJavaType<T> {
@SuppressWarnings("unchecked")
public EnumJavaType(Class<T> type) {
super( type, ImmutableMutabilityPlan.INSTANCE );
super( type, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -38,9 +38,8 @@ public class InstantJavaType extends AbstractTemporalJavaType<Instant>
*/
public static final InstantJavaType INSTANCE = new InstantJavaType();
@SuppressWarnings("unchecked")
public InstantJavaType() {
super( Instant.class, ImmutableMutabilityPlan.INSTANCE );
super( Instant.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -59,9 +59,8 @@ public interface JavaType<T> extends Serializable {
/**
* Retrieve the mutability plan for this Java type.
*/
@SuppressWarnings("unchecked")
default MutabilityPlan<T> getMutabilityPlan() {
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
default T getReplacement(T original, T target, SharedSessionContractImplementor session) {

View File

@ -36,9 +36,8 @@ public class LocalDateJavaType extends AbstractTemporalJavaType<LocalDate> {
*/
public static final LocalDateJavaType INSTANCE = new LocalDateJavaType();
@SuppressWarnings("unchecked")
public LocalDateJavaType() {
super( LocalDate.class, ImmutableMutabilityPlan.INSTANCE );
super( LocalDate.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -37,9 +37,8 @@ public class LocalDateTimeJavaType extends AbstractTemporalJavaType<LocalDateTim
*/
public static final LocalDateTimeJavaType INSTANCE = new LocalDateTimeJavaType();
@SuppressWarnings("unchecked")
public LocalDateTimeJavaType() {
super( LocalDateTime.class, ImmutableMutabilityPlan.INSTANCE );
super( LocalDateTime.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -39,9 +39,8 @@ public class LocalTimeJavaType extends AbstractTemporalJavaType<LocalTime> {
*/
public static final LocalTimeJavaType INSTANCE = new LocalTimeJavaType();
@SuppressWarnings("unchecked")
public LocalTimeJavaType() {
super( LocalTime.class, ImmutableMutabilityPlan.INSTANCE );
super( LocalTime.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -28,7 +28,7 @@ public class LocaleJavaType extends AbstractClassJavaType<Locale> {
}
public LocaleJavaType() {
super( Locale.class, ImmutableMutabilityPlan.INSTANCE, LocaleComparator.INSTANCE );
super( Locale.class, ImmutableMutabilityPlan.instance(), LocaleComparator.INSTANCE );
}
public String toString(Locale value) {

View File

@ -15,15 +15,15 @@ import org.hibernate.type.descriptor.WrapperOptions;
*/
public class ObjectArrayJavaType extends AbstractClassJavaType<Object[]> {
private final JavaType<Object>[] components;
private final JavaType[] components;
public ObjectArrayJavaType(JavaType<?>[] components) {
public ObjectArrayJavaType(JavaType[] components) {
super(
Object[].class,
ImmutableMutabilityPlan.INSTANCE,
new ComponentArrayComparator( (JavaType<Object>[]) components )
ImmutableMutabilityPlan.instance(),
new ComponentArrayComparator( components )
);
this.components = (JavaType<Object>[]) components;
this.components = components;
}
@Override

View File

@ -40,9 +40,8 @@ public class OffsetDateTimeJavaType extends AbstractTemporalJavaType<OffsetDateT
*/
public static final OffsetDateTimeJavaType INSTANCE = new OffsetDateTimeJavaType();
@SuppressWarnings("unchecked")
public OffsetDateTimeJavaType() {
super( OffsetDateTime.class, ImmutableMutabilityPlan.INSTANCE, OffsetDateTime.timeLineOrder() );
super( OffsetDateTime.class, ImmutableMutabilityPlan.instance(), OffsetDateTime.timeLineOrder() );
}
@Override

View File

@ -39,9 +39,8 @@ public class OffsetTimeJavaType extends AbstractTemporalJavaType<OffsetTime> {
*/
public static final OffsetTimeJavaType INSTANCE = new OffsetTimeJavaType();
@SuppressWarnings("unchecked")
public OffsetTimeJavaType() {
super( OffsetTime.class, ImmutableMutabilityPlan.INSTANCE );
super( OffsetTime.class, ImmutableMutabilityPlan.instance() );
}
@Override

View File

@ -54,10 +54,9 @@ public class SerializableJavaType<T extends Serializable> extends AbstractClassJ
super( type, mutabilityPlan == null ? createMutabilityPlan( type ) : mutabilityPlan );
}
@SuppressWarnings({ "unchecked" })
private static <T> MutabilityPlan<T> createMutabilityPlan(Class<T> type) {
if ( type.isAnnotationPresent( Immutable.class ) ) {
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
return (MutabilityPlan<T>) SerializableMutabilityPlan.INSTANCE;
}

View File

@ -28,7 +28,7 @@ public class TimeZoneJavaType extends AbstractClassJavaType<TimeZone> {
}
public TimeZoneJavaType() {
super( TimeZone.class, ImmutableMutabilityPlan.INSTANCE, TimeZoneComparator.INSTANCE );
super( TimeZone.class, ImmutableMutabilityPlan.instance(), TimeZoneComparator.INSTANCE );
}
public String toString(TimeZone value) {

View File

@ -31,7 +31,7 @@ public class ZoneOffsetJavaType extends AbstractClassJavaType<ZoneOffset> {
}
public ZoneOffsetJavaType() {
super( ZoneOffset.class, ImmutableMutabilityPlan.INSTANCE, ZoneOffsetComparator.INSTANCE );
super( ZoneOffset.class, ImmutableMutabilityPlan.instance(), ZoneOffsetComparator.INSTANCE );
}
public String toString(ZoneOffset value) {

View File

@ -40,9 +40,8 @@ public class ZonedDateTimeJavaType extends AbstractTemporalJavaType<ZonedDateTim
*/
public static final ZonedDateTimeJavaType INSTANCE = new ZonedDateTimeJavaType();
@SuppressWarnings("unchecked")
public ZonedDateTimeJavaType() {
super( ZonedDateTime.class, ImmutableMutabilityPlan.INSTANCE, ZonedDateTimeComparator.INSTANCE );
super( ZonedDateTime.class, ImmutableMutabilityPlan.instance(), ZonedDateTimeComparator.INSTANCE );
}
@Override

View File

@ -52,12 +52,11 @@ public class RegistryHelper {
);
}
@SuppressWarnings("unchecked")
public <J> MutabilityPlan<J> determineMutabilityPlan(Type javaType, TypeConfiguration typeConfiguration) {
final Class<J> javaTypeClass = determineJavaTypeClass( javaType );
if ( javaTypeClass.isAnnotationPresent( Immutable.class ) ) {
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
if ( javaTypeClass.isAnnotationPresent( Mutability.class ) ) {
@ -71,11 +70,11 @@ public class RegistryHelper {
}
if ( javaTypeClass.isEnum() ) {
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
if ( javaTypeClass.isPrimitive() ) {
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
if ( Serializable.class.isAssignableFrom( javaTypeClass ) ) {
@ -85,7 +84,6 @@ public class RegistryHelper {
return null;
}
@SuppressWarnings("unchecked")
private <J> JavaType<J> createTypeDescriptor(
Type javaType,
Function<Class<J>,MutabilityPlan<J>> mutabilityPlanResolver) {
@ -93,14 +91,14 @@ public class RegistryHelper {
if ( javaTypeClass.isEnum() ) {
// enums are unequivocally immutable
//noinspection rawtypes
//noinspection rawtypes, unchecked
return new EnumJavaType( javaTypeClass );
}
final MutabilityPlan<J> plan = mutabilityPlanResolver.apply( javaTypeClass );
if ( Serializable.class.isAssignableFrom( javaTypeClass ) ) {
//noinspection rawtypes
//noinspection rawtypes, unchecked
return new SerializableJavaType( javaTypeClass, plan );
}

View File

@ -27,7 +27,6 @@ public class ImmutableConvertedBasicTypeImpl<J> extends ConvertedBasicTypeImpl<J
@Override
protected MutabilityPlan<J> getMutabilityPlan() {
//noinspection unchecked
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
}

View File

@ -25,7 +25,6 @@ public class ImmutableNamedBasicTypeImpl<J> extends NamedBasicTypeImpl<J> {
@Override
protected MutabilityPlan<J> getMutabilityPlan() {
//noinspection unchecked
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
}

View File

@ -89,7 +89,7 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
@After
public void dropTestData() {
inTransaction(
(session) -> session.createQuery( "delete TheEntity" ).executeUpdate()
session -> session.createQuery( "delete TheEntity" ).executeUpdate()
);
}
@ -320,8 +320,7 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
@Override
public MutabilityPlan<PseudoMutableState> getMutabilityPlan() {
//noinspection unchecked
return ImmutableMutabilityPlan.INSTANCE;
return ImmutableMutabilityPlan.instance();
}
@Override