Skip to content

Commit a9da345

Browse files
committed
Some cleanups done automatically by IntelliJ with some revision by me
1 parent 6088005 commit a9da345

File tree

223 files changed

+544
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+544
-851
lines changed

hibernate-core/src/main/java/org/hibernate/DuplicateMappingException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DuplicateMappingException extends MappingException {
1515
/**
1616
* Enumeration of the types of things that can be duplicated.
1717
*/
18-
public static enum Type {
18+
public enum Type {
1919
/**
2020
* A duplicate entity definition was encountered.
2121
*/

hibernate-core/src/main/java/org/hibernate/action/internal/AbstractEntityInsertAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private void addCollectionKey(
213213
PersistenceContext persistenceContext) {
214214
if ( o instanceof PersistentCollection ) {
215215
final CollectionPersister collectionPersister = pluralAttributeMapping.getCollectionDescriptor();
216-
final Object key = ( (AbstractEntityPersister) getPersister() ).getCollectionKey(
216+
final Object key = AbstractEntityPersister.getCollectionKey(
217217
collectionPersister,
218218
getInstance(),
219219
persistenceContext.getEntry( getInstance() ),

hibernate-core/src/main/java/org/hibernate/binder/internal/BatchSizeBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public void bind(BatchSize batchSize, MetadataBuildingContext context, Component
3737
@Override
3838
public void bind(BatchSize batchSize, MetadataBuildingContext context, PersistentClass persistentClass, Property property) {
3939
final Value value = property.getValue();
40-
if ( value instanceof Collection ) {
41-
final Collection collection = (Collection) value;
40+
if ( value instanceof Collection collection ) {
4241
collection.setBatchSize( batchSize.size() );
4342
}
4443
else {

hibernate-core/src/main/java/org/hibernate/binder/internal/CommentBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public void bind(Comment comment, MetadataBuildingContext context, PersistentCla
3434
throw new AnnotationException( "One to many association '" + property.getName()
3535
+ "' was annotated '@Comment'");
3636
}
37-
else if ( value instanceof Collection ) {
38-
Collection collection = (Collection) value;
37+
else if ( value instanceof Collection collection ) {
3938
Table table = collection.getTable();
4039
// by default, the comment goes on the table
4140
if ( on.isEmpty() || table.getName().equalsIgnoreCase( on ) ) {

hibernate-core/src/main/java/org/hibernate/binder/internal/DiscriminatorOptionsBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
public class DiscriminatorOptionsBinder implements TypeBinder<DiscriminatorOptions> {
2323
@Override
2424
public void bind(DiscriminatorOptions options, MetadataBuildingContext context, PersistentClass persistentClass) {
25-
if ( persistentClass instanceof RootClass ) {
26-
final RootClass rootClass = (RootClass) persistentClass;
25+
if ( persistentClass instanceof RootClass rootClass ) {
2726
if ( !rootClass.hasDiscriminator() ) {
2827
throw new AnnotationException( "Root entity '" + rootClass.getEntityName()
2928
+ "' is annotated '@DiscriminatorOptions' but has no discriminator column" );

hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ public MetadataSources addJar(File jar) {
632632
* processing the contained mapping documents.
633633
*/
634634
public MetadataSources addDirectory(File dir) {
635-
File[] files = dir.listFiles();
636-
if ( files != null && files.length > 0 ) {
635+
final File[] files = dir.listFiles();
636+
if ( files != null ) {
637637
for ( File file : files ) {
638638
if ( file.isDirectory() ) {
639639
addDirectory( file );

hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ private void addMappingReference(MappingReference mappingReference) {
143143
}
144144

145145
private static CacheRegionDefinition parseCacheRegionDefinition(Object cacheDeclaration) {
146-
if ( cacheDeclaration instanceof JaxbCfgEntityCacheType ) {
147-
final JaxbCfgEntityCacheType jaxbClassCache = (JaxbCfgEntityCacheType) cacheDeclaration;
146+
if ( cacheDeclaration instanceof JaxbCfgEntityCacheType jaxbClassCache ) {
148147
return new CacheRegionDefinition(
149148
CacheRegionDefinition.CacheRegionType.ENTITY,
150149
jaxbClassCache.getClazz(),

hibernate-core/src/main/java/org/hibernate/boot/jaxb/Origin.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ public boolean equals(Object o) {
4949
if ( this == o ) {
5050
return true;
5151
}
52-
if ( !( o instanceof Origin ) ) {
52+
if ( !(o instanceof Origin other) ) {
5353
return false;
5454
}
55-
56-
final Origin other = (Origin) o;
5755
return type == other.type
58-
&& Objects.equals( name, other.name );
56+
&& Objects.equals( name, other.name );
5957

6058
}
6159

hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ else if ( source instanceof JaxbHbmMapType map ) {
19141914
}
19151915
target.setOrderBy( map.getOrderBy() );
19161916

1917-
transferMapKey( (JaxbHbmMapType) source, target );
1917+
transferMapKey( map, target );
19181918
target.setClassification( LimitedCollectionClassification.MAP );
19191919
}
19201920
else if ( source instanceof JaxbHbmIdBagCollectionType ) {

hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/JpaOrmXmlEventReader.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private StartElement wrap(StartElement startElement) {
8181
// so that the event we ask it to generate for us has the same location info
8282
xmlEventFactory.setLocation( startElement.getLocation() );
8383
return xmlEventFactory.createStartElement(
84-
new QName( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri(), startElement.getName().getLocalPart() ),
84+
new QName( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri(), startElement.getName().getLocalPart() ),
8585
newElementAttributeList.iterator(),
8686
newNamespaceList.iterator()
8787
);
@@ -100,7 +100,6 @@ private List<Attribute> mapAttributes(StartElement startElement) {
100100
return mappedAttributes;
101101
}
102102

103-
@SuppressWarnings("unchecked")
104103
private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElement) {
105104
return startElement.getAttributes();
106105
}
@@ -143,13 +142,12 @@ private List<Namespace> mapNamespaces(Iterator<Namespace> originalNamespaceItera
143142
}
144143

145144
if ( mappedNamespaces.isEmpty() ) {
146-
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri() ) );
145+
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri() ) );
147146
}
148147

149148
return mappedNamespaces;
150149
}
151150

152-
@SuppressWarnings("unchecked")
153151
private Iterator<Namespace> existingXmlNamespacesIterator(StartElement startElement) {
154152
return startElement.getNamespaces();
155153
}
@@ -159,7 +157,7 @@ private Namespace mapNamespace(Namespace originalNamespace) {
159157
// this is a namespace "to map" so map it
160158
return xmlEventFactory.createNamespace(
161159
originalNamespace.getPrefix(),
162-
MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri()
160+
MappingXsdSupport.latestJpaDescriptor().getNamespaceUri()
163161
);
164162
}
165163

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

181-
@SuppressWarnings("unchecked")
182179
private Iterator<Namespace> existingXmlNamespacesIterator(EndElement endElement) {
183180
return endElement.getNamespaces();
184181
}

0 commit comments

Comments
 (0)