Skip to content

Commit 9f1b523

Browse files
committed
HBX-3194: Remove unused Class parameter from method EntityModelDetector#visitProperty()
Signed-off-by: Koen Aers <[email protected]>
1 parent 40a5c78 commit 9f1b523

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

orm/src/main/java/org/hibernate/tool/internal/export/lint/BadCachingDetector.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ public String getName() {
3030
}
3131

3232
@Override
33-
protected void visitProperty(PersistentClass clazz, Property property, IssueCollector collector) {
33+
protected void visitProperty(Property property, IssueCollector collector) {
3434
Value value = property.getValue();
3535

36-
if(value instanceof Collection) {
37-
Collection col = (Collection) value;
38-
if(col.getCacheConcurrencyStrategy()!=null) { // caching is enabled
36+
if(value instanceof Collection col) {
37+
if(col.getCacheConcurrencyStrategy()!=null) { // caching is enabled
3938
if (!col.getElement().isSimpleValue()) {
4039
String entityName = (String) col.getElement().accept( new EntityNameFromValueVisitor() );
4140

orm/src/main/java/org/hibernate/tool/internal/export/lint/EntityModelDetector.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@
1717
*/
1818
package org.hibernate.tool.internal.export.lint;
1919

20-
import java.util.Iterator;
21-
2220
import org.hibernate.mapping.PersistentClass;
2321
import org.hibernate.mapping.Property;
2422

2523
public abstract class EntityModelDetector extends Detector {
2624

2725
public void visit(IssueCollector collector) {
28-
for (Iterator<PersistentClass> iter = getMetadata().getEntityBindings().iterator(); iter.hasNext();) {
29-
PersistentClass clazz = iter.next();
30-
this.visit(clazz, collector);
31-
}
26+
for (PersistentClass clazz : getMetadata().getEntityBindings()) {
27+
this.visit(clazz, collector);
28+
}
3229
}
3330

3431
protected void visit(PersistentClass clazz, IssueCollector collector) {
@@ -37,13 +34,13 @@ protected void visit(PersistentClass clazz, IssueCollector collector) {
3734

3835
private void visitProperties(PersistentClass clazz, IssueCollector collector) {
3936
if(clazz.hasIdentifierProperty()) {
40-
this.visitProperty(clazz, clazz.getIdentifierProperty(), collector);
37+
this.visitProperty(clazz.getIdentifierProperty(), collector);
4138
}
4239
for (Property property : clazz.getProperties()) {
43-
this.visitProperty(clazz, property, collector);
40+
this.visitProperty(property, collector);
4441
}
4542
}
4643

47-
protected abstract void visitProperty(PersistentClass clazz, Property property, IssueCollector collector);
44+
protected abstract void visitProperty(Property property, IssueCollector collector);
4845

4946
}

orm/src/main/java/org/hibernate/tool/internal/export/lint/InstrumentationDetector.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,23 @@ protected void visit(PersistentClass clazz, IssueCollector collector) {
7070
} else if(enhanceEnabled){
7171
Class<?>[] interfaces = mappedClass.getInterfaces();
7272
boolean enhanced = false;
73-
for (int i = 0; i < interfaces.length; i++) {
74-
Class<?> intface = interfaces[i];
75-
if(intface.getName().equals(Managed.class.getName())) {
76-
enhanced = true;
77-
}
78-
}
73+
for (Class<?> intface : interfaces) {
74+
if (intface.getName().equals(Managed.class.getName())) {
75+
enhanced = true;
76+
break;
77+
}
78+
}
7979

80-
if (enhanceEnabled && !enhanced) {
80+
if (!enhanced) {
8181
collector.reportIssue( new Issue("LAZY_NOT_INSTRUMENTED", Issue.HIGH_PRIORITY, "'" + clazz.getEntityName() + "' has lazy='false', but its class '" + mappedClass.getName() + "' has not been instrumented with javaassist") );
8282
return;
83-
} else {
84-
// unknown bytecodeprovider...can't really check for that.
8583
}
8684

8785
}
8886
}
8987

9088
@Override
9189
protected void visitProperty(
92-
PersistentClass clazz,
9390
Property property,
9491
IssueCollector collector) {
9592
}

orm/src/main/java/org/hibernate/tool/internal/export/lint/ShadowedIdentifierDetector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.hibernate.tool.internal.export.lint;
1919

20-
import org.hibernate.mapping.PersistentClass;
2120
import org.hibernate.mapping.Property;
2221

2322
public class ShadowedIdentifierDetector extends EntityModelDetector {
@@ -27,7 +26,7 @@ public String getName() {
2726
}
2827

2928
@Override
30-
protected void visitProperty(PersistentClass clazz, Property property, IssueCollector collector) {
29+
protected void visitProperty(Property property, IssueCollector collector) {
3130
if(property.getName().equals("id")) {
3231
if (property != property.getPersistentClass().getIdentifierProperty()) {
3332
collector.reportIssue(new Issue("ID_SHADOWED", Issue.LOW_PRIORITY, property.getPersistentClass().getEntityName() + " has a normal property named 'id'. This can cause issues since HQL queries will always interpret 'id' as the identifier and not the concrete property"));

0 commit comments

Comments
 (0)