Skip to content

Commit e8f6859

Browse files
committed
some automated code cleanups from IntelliJ
1 parent 06b3d08 commit e8f6859

File tree

233 files changed

+566
-872
lines changed

Some content is hidden

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

233 files changed

+566
-872
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ 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
}
5555

56-
final Origin other = (Origin) o;
5756
return type == other.type
5857
&& Objects.equals( name, other.name );
5958

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 & 4 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
);
@@ -143,7 +143,7 @@ private List<Namespace> mapNamespaces(Iterator<Namespace> originalNamespaceItera
143143
}
144144

145145
if ( mappedNamespaces.isEmpty() ) {
146-
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri() ) );
146+
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri() ) );
147147
}
148148

149149
return mappedNamespaces;
@@ -159,7 +159,7 @@ private Namespace mapNamespace(Namespace originalNamespace) {
159159
// this is a namespace "to map" so map it
160160
return xmlEventFactory.createNamespace(
161161
originalNamespace.getPrefix(),
162-
MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri()
162+
MappingXsdSupport.latestJpaDescriptor().getNamespaceUri()
163163
);
164164
}
165165

@@ -173,7 +173,7 @@ private XMLEvent wrap(EndElement endElement) {
173173
// so that the event we ask it to generate for us has the same location info
174174
xmlEventFactory.setLocation( endElement.getLocation() );
175175
return xmlEventFactory.createEndElement(
176-
new QName( MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri(), endElement.getName().getLocalPart() ),
176+
new QName( MappingXsdSupport.latestJpaDescriptor().getNamespaceUri(), endElement.getName().getLocalPart() ),
177177
targetNamespaces.iterator()
178178
);
179179
}

0 commit comments

Comments
 (0)