Skip to content

Commit a0696fa

Browse files
committed
misc cleanups in metamodel stuff
including lots of 'var'
1 parent d95e14a commit a0696fa

File tree

3 files changed

+108
-126
lines changed

3 files changed

+108
-126
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationProcess.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static void process(
3535
EntityPersisterConcurrentMap entityPersisterMap,
3636
Map<String, CollectionPersister> collectionPersisterMap,
3737
RuntimeModelCreationContext creationContext) {
38-
final MappingModelCreationProcess process = new MappingModelCreationProcess(
38+
final var process = new MappingModelCreationProcess(
3939
entityPersisterMap,
4040
collectionPersisterMap,
4141
creationContext
@@ -75,21 +75,21 @@ public SqmFunctionRegistry getSqmFunctionRegistry() {
7575
* Instance-level trigger for {@link #process}
7676
*/
7777
private void execute() {
78-
for ( EntityPersister entityPersister : entityPersisterMap.values() ) {
78+
for ( var entityPersister : entityPersisterMap.values() ) {
7979
if ( entityPersister instanceof InFlightEntityMappingType inFlightEntityMappingType ) {
8080
inFlightEntityMappingType.linkWithSuperType( this );
8181
}
8282
}
8383

84-
for ( EntityPersister entityPersister : entityPersisterMap.values() ) {
84+
for ( var entityPersister : entityPersisterMap.values() ) {
8585
currentlyProcessingRole = entityPersister.getEntityName();
8686

8787
if ( entityPersister instanceof InFlightEntityMappingType inFlightEntityMappingType ) {
8888
inFlightEntityMappingType.prepareMappingModel( this );
8989
}
9090
}
9191

92-
for ( CollectionPersister collectionPersister : collectionPersisterMap.values() ) {
92+
for ( var collectionPersister : collectionPersisterMap.values() ) {
9393
if ( collectionPersister instanceof InFlightCollectionMapping inFlightCollectionMapping ) {
9494
inFlightCollectionMapping.prepareMappingModel( this );
9595
}
@@ -103,15 +103,15 @@ private void executePostInitCallbacks() {
103103

104104
Map<PostInitCallbackEntry, Exception> exceptions = new HashMap<>();
105105
while ( postInitCallbacks != null && !postInitCallbacks.isEmpty() ) {
106-
// copy to avoid CCME
107-
final ArrayList<PostInitCallbackEntry> copy = new ArrayList<>( postInitCallbacks );
106+
// cope the callback list to avoid CCME
107+
final var callbacks = new ArrayList<>( postInitCallbacks );
108108

109-
// NOTE : this is *not* the same as the lengths between `copy` and `postInitCallbacks`
109+
// NOTE: this is *not* the same as the lengths between `callbacks` and `postInitCallbacks`
110110
boolean anyCompleted = false;
111111

112112
//noinspection ForLoopReplaceableByForEach
113-
for ( int i = 0; i < copy.size(); i++ ) {
114-
final PostInitCallbackEntry callbackEntry = copy.get( i );
113+
for ( int i = 0; i < callbacks.size(); i++ ) {
114+
final var callbackEntry = callbacks.get( i );
115115
try {
116116
final boolean completed = callbackEntry.process();
117117
if ( completed ) {
@@ -123,14 +123,14 @@ private void executePostInitCallbacks() {
123123
catch (Exception e) {
124124
if ( e instanceof NonTransientException ) {
125125
MAPPING_MODEL_CREATION_MESSAGE_LOGGER.debugf(
126-
"Mapping-model creation encountered non-transient error : %s",
126+
"Mapping-model creation encountered non-transient error: %s",
127127
e
128128
);
129129
throw e;
130130
}
131131
exceptions.put( callbackEntry, e );
132132

133-
final String format = "Mapping-model creation encountered (possibly) transient error : %s";
133+
final String format = "Mapping-model creation encountered (possibly) transient error: %s";
134134
if ( MAPPING_MODEL_CREATION_MESSAGE_LOGGER.isTraceEnabled() ) {
135135
MAPPING_MODEL_CREATION_MESSAGE_LOGGER.tracef( e, format, e );
136136
}
@@ -142,7 +142,7 @@ private void executePostInitCallbacks() {
142142

143143
if ( !anyCompleted ) {
144144
// none of the remaining callbacks could complete fully, this is an error
145-
final StringBuilder buff = new StringBuilder(
145+
final var buff = new StringBuilder(
146146
"PostInitCallback queue could not be processed..."
147147
);
148148
postInitCallbacks.forEach(
@@ -151,9 +151,8 @@ private void executePostInitCallbacks() {
151151
);
152152
buff.append( EOL );
153153

154-
final IllegalStateException illegalStateException = new IllegalStateException( buff.toString() );
155-
156-
for ( Map.Entry<PostInitCallbackEntry, Exception> entry : exceptions.entrySet() ) {
154+
final var illegalStateException = new IllegalStateException( buff.toString() );
155+
for ( var entry : exceptions.entrySet() ) {
157156
illegalStateException.addSuppressed( entry.getValue() );
158157
}
159158
throw illegalStateException;
@@ -165,10 +164,8 @@ public <T extends ModelPart> T processSubPart(
165164
String localName,
166165
SubPartMappingProducer<T> subPartMappingProducer) {
167166
assert currentlyProcessingRole != null;
168-
169167
final String initialRole = currentlyProcessingRole;
170168
currentlyProcessingRole = currentlyProcessingRole + '#' + localName;
171-
172169
try {
173170
return subPartMappingProducer.produceSubMapping( currentlyProcessingRole, this );
174171
}
@@ -196,7 +193,7 @@ public void withForeignKey(ModelPart keyOwner, Consumer<ForeignKeyDescriptor> co
196193
}
197194

198195
private void withForeignKey(NavigableRole navigableRole, Consumer<ForeignKeyDescriptor> consumer) {
199-
final ForeignKeyDescriptor keyDescriptor = keyDescriptorMap.get( navigableRole );
196+
final var keyDescriptor = keyDescriptorMap.get( navigableRole );
200197
if ( keyDescriptor != null ) {
201198
consumer.accept( keyDescriptor );
202199
}
@@ -215,9 +212,8 @@ private void withForeignKey(NavigableRole navigableRole, Consumer<ForeignKeyDesc
215212
}
216213

217214
public void registerForeignKey(ModelPart keyOwner, ForeignKeyDescriptor keyDescriptor) {
218-
final NavigableRole navigableRole = keyOwner.getNavigableRole();
215+
final var navigableRole = keyOwner.getNavigableRole();
219216
keyDescriptorMap.put( navigableRole, keyDescriptor );
220-
221217
final var waitingConsumers = keyDescriptorWaitingConsumerMap.remove( navigableRole );
222218
if ( waitingConsumers != null ) {
223219
for ( int i = 0; i < waitingConsumers.size(); i++ ) {

0 commit comments

Comments
 (0)