Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DuplicateMappingException extends MappingException {
/**
* Enumeration of the types of things that can be duplicated.
*/
public static enum Type {
public enum Type {
/**
* A duplicate entity definition was encountered.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private void addCollectionKey(
PersistenceContext persistenceContext) {
if ( o instanceof PersistentCollection ) {
final CollectionPersister collectionPersister = pluralAttributeMapping.getCollectionDescriptor();
final Object key = ( (AbstractEntityPersister) getPersister() ).getCollectionKey(
final Object key = AbstractEntityPersister.getCollectionKey(
collectionPersister,
getInstance(),
persistenceContext.getEntry( getInstance() ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public void bind(BatchSize batchSize, MetadataBuildingContext context, Component
@Override
public void bind(BatchSize batchSize, MetadataBuildingContext context, PersistentClass persistentClass, Property property) {
final Value value = property.getValue();
if ( value instanceof Collection ) {
final Collection collection = (Collection) value;
if ( value instanceof Collection collection ) {
collection.setBatchSize( batchSize.size() );
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
throw new AnnotationException( "One to many association '" + property.getName()
+ "' was annotated '@Comment'");
}
else if ( value instanceof Collection ) {
Collection collection = (Collection) value;
else if ( value instanceof Collection collection ) {
Table table = collection.getTable();
// by default, the comment goes on the table
if ( on.isEmpty() || table.getName().equalsIgnoreCase( on ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
public class DiscriminatorOptionsBinder implements TypeBinder<DiscriminatorOptions> {
@Override
public void bind(DiscriminatorOptions options, MetadataBuildingContext context, PersistentClass persistentClass) {
if ( persistentClass instanceof RootClass ) {
final RootClass rootClass = (RootClass) persistentClass;
if ( persistentClass instanceof RootClass rootClass ) {
if ( !rootClass.hasDiscriminator() ) {
throw new AnnotationException( "Root entity '" + rootClass.getEntityName()
+ "' is annotated '@DiscriminatorOptions' but has no discriminator column" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ public MetadataSources addJar(File jar) {
* processing the contained mapping documents.
*/
public MetadataSources addDirectory(File dir) {
File[] files = dir.listFiles();
if ( files != null && files.length > 0 ) {
final File[] files = dir.listFiles();
if ( files != null ) {
for ( File file : files ) {
if ( file.isDirectory() ) {
addDirectory( file );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ private void addMappingReference(MappingReference mappingReference) {
}

private static CacheRegionDefinition parseCacheRegionDefinition(Object cacheDeclaration) {
if ( cacheDeclaration instanceof JaxbCfgEntityCacheType ) {
final JaxbCfgEntityCacheType jaxbClassCache = (JaxbCfgEntityCacheType) cacheDeclaration;
if ( cacheDeclaration instanceof JaxbCfgEntityCacheType jaxbClassCache ) {
return new CacheRegionDefinition(
CacheRegionDefinition.CacheRegionType.ENTITY,
jaxbClassCache.getClazz(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( !( o instanceof Origin ) ) {
if ( !(o instanceof Origin other) ) {
return false;
}

final Origin other = (Origin) o;
return type == other.type
&& Objects.equals( name, other.name );
&& Objects.equals( name, other.name );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ else if ( source instanceof JaxbHbmMapType map ) {
}
target.setOrderBy( map.getOrderBy() );

transferMapKey( (JaxbHbmMapType) source, target );
transferMapKey( map, target );
target.setClassification( LimitedCollectionClassification.MAP );
}
else if ( source instanceof JaxbHbmIdBagCollectionType ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private StartElement wrap(StartElement startElement) {
// so that the event we ask it to generate for us has the same location info
xmlEventFactory.setLocation( startElement.getLocation() );
return xmlEventFactory.createStartElement(
new QName( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri(), startElement.getName().getLocalPart() ),
new QName( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri(), startElement.getName().getLocalPart() ),
newElementAttributeList.iterator(),
newNamespaceList.iterator()
);
Expand All @@ -100,7 +100,6 @@ private List<Attribute> mapAttributes(StartElement startElement) {
return mappedAttributes;
}

@SuppressWarnings("unchecked")
private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElement) {
return startElement.getAttributes();
}
Expand Down Expand Up @@ -143,13 +142,12 @@ private List<Namespace> mapNamespaces(Iterator<Namespace> originalNamespaceItera
}

if ( mappedNamespaces.isEmpty() ) {
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri() ) );
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri() ) );
}

return mappedNamespaces;
}

@SuppressWarnings("unchecked")
private Iterator<Namespace> existingXmlNamespacesIterator(StartElement startElement) {
return startElement.getNamespaces();
}
Expand All @@ -159,7 +157,7 @@ private Namespace mapNamespace(Namespace originalNamespace) {
// this is a namespace "to map" so map it
return xmlEventFactory.createNamespace(
originalNamespace.getPrefix(),
MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri()
MappingXsdSupport.latestJpaDescriptor().getNamespaceUri()
);
}

Expand All @@ -173,12 +171,11 @@ private XMLEvent wrap(EndElement endElement) {
// so that the event we ask it to generate for us has the same location info
xmlEventFactory.setLocation( endElement.getLocation() );
return xmlEventFactory.createEndElement(
new QName( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri(), endElement.getName().getLocalPart() ),
new QName( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri(), endElement.getName().getLocalPart() ),
targetNamespaces.iterator()
);
}

@SuppressWarnings("unchecked")
private Iterator<Namespace> existingXmlNamespacesIterator(EndElement endElement) {
return endElement.getNamespaces();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ public boolean matches(String publicId, String systemId) {
}

if ( systemId != null ) {
if ( systemId.startsWith( httpBase )
|| systemId.startsWith( httpsBase ) ) {
return true;
}
return systemId.startsWith( httpBase )
|| systemId.startsWith( httpsBase );
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,19 @@ private XMLStreamConstantsUtils() {
* Get the human readable event name for the numeric event id
*/
public static String getEventName(int eventId) {
switch (eventId) {
case XMLStreamConstants.START_ELEMENT:
return "StartElementEvent";
case XMLStreamConstants.END_ELEMENT:
return "EndElementEvent";
case XMLStreamConstants.PROCESSING_INSTRUCTION:
return "ProcessingInstructionEvent";
case XMLStreamConstants.CHARACTERS:
return "CharacterEvent";
case XMLStreamConstants.COMMENT:
return "CommentEvent";
case XMLStreamConstants.START_DOCUMENT:
return "StartDocumentEvent";
case XMLStreamConstants.END_DOCUMENT:
return "EndDocumentEvent";
case XMLStreamConstants.ENTITY_REFERENCE:
return "EntityReferenceEvent";
case XMLStreamConstants.ATTRIBUTE:
return "AttributeBase";
case XMLStreamConstants.DTD:
return "DTDEvent";
case XMLStreamConstants.CDATA:
return "CDATA";
}
return "UNKNOWN_EVENT_TYPE";
return switch ( eventId ) {
case XMLStreamConstants.START_ELEMENT -> "StartElementEvent";
case XMLStreamConstants.END_ELEMENT -> "EndElementEvent";
case XMLStreamConstants.PROCESSING_INSTRUCTION -> "ProcessingInstructionEvent";
case XMLStreamConstants.CHARACTERS -> "CharacterEvent";
case XMLStreamConstants.COMMENT -> "CommentEvent";
case XMLStreamConstants.START_DOCUMENT -> "StartDocumentEvent";
case XMLStreamConstants.END_DOCUMENT -> "EndDocumentEvent";
case XMLStreamConstants.ENTITY_REFERENCE -> "EntityReferenceEvent";
case XMLStreamConstants.ATTRIBUTE -> "AttributeBase";
case XMLStreamConstants.DTD -> "DTDEvent";
case XMLStreamConstants.CDATA -> "CDATA";
default -> "UNKNOWN_EVENT_TYPE";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( !( o instanceof IdentifierGeneratorDefinition ) ) {
if ( !(o instanceof IdentifierGeneratorDefinition that) ) {
return false;
}

IdentifierGeneratorDefinition that = (IdentifierGeneratorDefinition) o;
return Objects.equals(name, that.name)
&& Objects.equals(strategy, that.strategy)
&& Objects.equals(parameters, that.parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ private static void validateComponent(Component component, String basePath, bool
if ( value instanceof Component c ) {
validateComponent( c, qualify( basePath, property.getName() ), inArray );
}
else if ( value instanceof ToOne ) {
final ToOne toOne = (ToOne) value;
else if ( value instanceof ToOne toOne ) {
if ( inArray && toOne.getReferencedPropertyName() != null ) {
throw new AnnotationException(
"Property '" + qualify( basePath, property.getName() )
Expand All @@ -210,8 +209,7 @@ else if ( value instanceof ToOne ) {
);
}
}
else if ( value instanceof Collection ) {
final Collection collection = (Collection) value;
else if ( value instanceof Collection collection ) {
if ( inArray && collection.getMappedByProperty() != null ) {
throw new AnnotationException(
"Property '" + qualify( basePath, property.getName() )
Expand Down Expand Up @@ -310,8 +308,7 @@ else if ( component.getInstantiatorPropertyNames() != null ) {
}

private static void addColumns(ArrayList<Column> orderedColumns, Value value) {
if ( value instanceof Component ) {
final Component subComponent = (Component) value;
if ( value instanceof Component subComponent ) {
if ( subComponent.getAggregateColumn() == null ) {
for ( Property property : subComponent.getProperties() ) {
addColumns( orderedColumns, property.getValue() );
Expand All @@ -329,8 +326,7 @@ private static void addColumns(ArrayList<Column> orderedColumns, Value value) {
private static boolean addColumns(ArrayList<Column> orderedColumns, Component component, String structColumnName) {
for ( Property property : component.getProperties() ) {
final Value value = property.getValue();
if ( value instanceof Component ) {
final Component subComponent = (Component) value;
if ( value instanceof Component subComponent ) {
if ( subComponent.getAggregateColumn() == null ) {
if ( addColumns( orderedColumns, subComponent, structColumnName ) ) {
return true;
Expand Down Expand Up @@ -363,8 +359,7 @@ else if ( structColumnName.equals( subComponent.getAggregateColumn().getName() )
private void validateSupportedColumnTypes(String basePath, Component component) {
for ( Property property : component.getProperties() ) {
final Value value = property.getValue();
if ( value instanceof Component ) {
final Component subComponent = (Component) value;
if ( value instanceof Component subComponent ) {
if ( subComponent.getAggregateColumn() == null ) {
validateSupportedColumnTypes( qualify( basePath, property.getName() ), subComponent );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ Property resolveMapsId() {
final PersistentClass persistentClass = getPropertyHolder().getPersistentClass();
final KeyValue identifier = persistentClass.getIdentifier();
try {
if ( identifier instanceof Component) {
if ( identifier instanceof Component embeddedIdType ) {
// an @EmbeddedId
final Component embeddedIdType = (Component) identifier;
return embeddedIdType.getProperty( getMapsId() );
}
else {
Expand Down Expand Up @@ -606,7 +605,7 @@ public Identifier getReferencedColumnName() {
);
}
final Selectable selectable = value.getSelectables().get( 0 );
if ( !( selectable instanceof Column ) ) {
if ( !(selectable instanceof Column column) ) {
throw new AnnotationException(
String.format(
Locale.ENGLISH,
Expand All @@ -628,7 +627,6 @@ public Identifier getReferencedColumnName() {
)
);
}
final Column column = (Column) selectable;
return column.getNameIdentifier( getBuildingContext() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -2299,9 +2300,7 @@ private void bindFiltersInHierarchy() {
private void bindFilters(AnnotationTarget element) {
final Filters filters = getOverridableAnnotation( element, Filters.class, context );
if ( filters != null ) {
for ( Filter filter : filters.value() ) {
this.filters.add( filter );
}
Collections.addAll( this.filters, filters.value() );
}
final Filter filter = element.getDirectAnnotationUsage( Filter.class );
if ( filter != null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ public static <A extends Annotation> void prepareForUse(
}
collectBaselineProperties(
creationContext.getProperty() != null
? (SimpleValue) creationContext.getProperty().getValue()
: (SimpleValue) creationContext.getPersistentClass().getIdentifierProperty().getValue(),
? creationContext.getProperty().getValue()
: creationContext.getPersistentClass().getIdentifierProperty().getValue(),
creationContext.getDatabase().getDialect(),
creationContext.getRootClass(),
properties::setProperty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ else if ( explicitJdbcType != null ) {
// see if there is a registered BasicType for this JavaType and,
// if so, use it. This mimics the legacy handling.
final BasicType registeredType;
if ( reflectedJtd instanceof BasicPluralJavaType<?> ) {
final BasicPluralJavaType<?> containerJtd = (BasicPluralJavaType<?>) reflectedJtd;
if ( reflectedJtd instanceof BasicPluralJavaType<?> containerJtd ) {
final JavaType<?> elementJtd = containerJtd.getElementJavaType();
final BasicType registeredElementType;
if ( elementJtd instanceof EnumJavaType ) {
Expand Down Expand Up @@ -242,8 +241,7 @@ else if ( reflectedJtd instanceof SerializableJavaType
// NOTE : yes it's an odd case, but easy to implement here, so...
Integer length = null;
Integer scale = null;
if ( selectable instanceof Column ) {
final Column column = (Column) selectable;
if ( selectable instanceof Column column ) {
if ( column.getPrecision() != null && column.getPrecision() > 0 ) {
length = column.getPrecision();
scale = column.getScale();
Expand Down Expand Up @@ -301,8 +299,7 @@ public static <T> BasicType<T> resolveSqlTypeIndicators(
JdbcTypeIndicators stdIndicators,
BasicType<T> resolved,
JavaType<T> domainJtd) {
if ( resolved instanceof AdjustableBasicType ) {
final AdjustableBasicType<T> indicatorCapable = (AdjustableBasicType<T>) resolved;
if ( resolved instanceof AdjustableBasicType<T> indicatorCapable ) {
final BasicType<T> indicatedType = indicatorCapable.resolveIndicatedType( stdIndicators, domainJtd );
return indicatedType != null ? indicatedType : resolved;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
return impl;
}

@SuppressWarnings({ "rawtypes", "unchecked" })
private static void handleXmlMappings(
MetadataSources sources,
ManagedResourcesImpl impl,
Expand All @@ -61,8 +60,8 @@
);
return;
}
impl.mappingFileBindings.addAll( (List) sources.getXmlBindings() );
impl.mappingFileBindings.addAll( sources.getXmlBindings() );
}

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
MetadataSources.getXmlBindings
should be avoided because it has been deprecated.

public ManagedResourcesImpl() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static class Builder {
private String implicitDiscriminatorColumnName;
private String implicitPackageName;
private boolean autoImportEnabled;
private EnumSet<CascadeType> implicitCascadeTypes;
private final EnumSet<CascadeType> implicitCascadeTypes;
private jakarta.persistence.AccessType implicitPropertyAccessType;
private String implicitPropertyAccessorName;
private boolean entitiesImplicitlyLazy;
Expand Down
Loading
Loading