Skip to content

Commit f5a11b3

Browse files
committed
HBX-2789: Review WrapperFactory class and create only new Wrapper intances
- Add new abstract class 'org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper' that implements 'org.hibernate.tool.orm.jbt.api.wrp.Wrapper' and overrides method 'equals(Object)' - Make all Wrapper implementations extend the above new class Signed-off-by: Koen Aers <[email protected]>
1 parent 4bc64c4 commit f5a11b3

36 files changed

+153
-36
lines changed

jbt/src/main/java/org/hibernate/tool/orm/jbt/api/wrp/Wrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
public interface Wrapper {
44

55
default Object getWrappedObject() { return this; }
6-
6+
77
}

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/ArtifactCollectorWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
import org.hibernate.tool.api.export.ArtifactCollector;
77
import org.hibernate.tool.internal.export.common.DefaultArtifactCollector;
88
import org.hibernate.tool.orm.jbt.api.wrp.ArtifactCollectorWrapper;
9+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
910

1011
public class ArtifactCollectorWrapperFactory {
1112

1213
public static ArtifactCollectorWrapper createArtifactCollectorWrapper() {
1314
return new ArtifactCollectorWrapperImpl();
1415
}
1516

16-
private static class ArtifactCollectorWrapperImpl implements ArtifactCollectorWrapper {
17+
private static class ArtifactCollectorWrapperImpl
18+
extends AbstractWrapper
19+
implements ArtifactCollectorWrapper {
1720

1821
private ArtifactCollector wrappedArtifactCollector = new DefaultArtifactCollector();
1922

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/Cfg2HbmToolWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
import org.hibernate.tool.orm.jbt.api.wrp.PersistentClassWrapper;
1111
import org.hibernate.tool.orm.jbt.api.wrp.PropertyWrapper;
1212
import org.hibernate.tool.orm.jbt.api.wrp.Wrapper;
13+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
1314

1415
public class Cfg2HbmToolWrapperFactory {
1516

1617
public static Cfg2HbmToolWrapper createCfg2HbmToolWrapper() {
1718
return new Cfg2HbmToolWrapperImpl();
1819
}
1920

20-
private static class Cfg2HbmToolWrapperImpl implements Cfg2HbmToolWrapper {
21+
private static class Cfg2HbmToolWrapperImpl
22+
extends AbstractWrapper
23+
implements Cfg2HbmToolWrapper {
2124

2225
private Cfg2HbmTool wrappedCfg2HbmTool = new Cfg2HbmTool();
2326

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/ClassMetadataWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.hibernate.tool.orm.jbt.api.wrp.ClassMetadataWrapper;
77
import org.hibernate.tool.orm.jbt.api.wrp.SessionWrapper;
88
import org.hibernate.tool.orm.jbt.api.wrp.TypeWrapper;
9+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
910
import org.hibernate.type.Type;
1011

1112
public class ClassMetadataWrapperFactory {
@@ -14,7 +15,9 @@ public static ClassMetadataWrapper createClassMetadataWrapper(final EntityPersis
1415
return new ClassMetadataWrapperImpl(entityPersister);
1516
}
1617

17-
private static class ClassMetadataWrapperImpl implements ClassMetadataWrapper {
18+
private static class ClassMetadataWrapperImpl
19+
extends AbstractWrapper
20+
implements ClassMetadataWrapper {
1821

1922
private EntityPersister wrappedClassMetadata = null;
2023
private TypeWrapper[] propertyTypeWrappers = null;

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/CollectionMetadataWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.hibernate.persister.collection.CollectionPersister;
44
import org.hibernate.tool.orm.jbt.api.wrp.CollectionMetadataWrapper;
55
import org.hibernate.tool.orm.jbt.api.wrp.TypeWrapper;
6+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
67
import org.hibernate.type.Type;
78

89
public class CollectionMetadataWrapperFactory {
@@ -11,7 +12,9 @@ public static CollectionMetadataWrapper createCollectionMetadataWrapper(final Co
1112
return new CollectionMetadataWrapperImpl(collectionPersister);
1213
}
1314

14-
private static class CollectionMetadataWrapperImpl implements CollectionMetadataWrapper {
15+
private static class CollectionMetadataWrapperImpl
16+
extends AbstractWrapper
17+
implements CollectionMetadataWrapper {
1518

1619
private CollectionPersister wrappedCollectionMetadata = null;
1720

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/ColumnWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.hibernate.tool.orm.jbt.api.wrp.ColumnWrapper;
77
import org.hibernate.tool.orm.jbt.api.wrp.ConfigurationWrapper;
88
import org.hibernate.tool.orm.jbt.api.wrp.ValueWrapper;
9+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
910
import org.hibernate.tool.orm.jbt.util.MetadataHelper;
1011

1112
public class ColumnWrapperFactory {
@@ -18,7 +19,9 @@ public static ColumnWrapper createColumnWrapper(final Column column) {
1819
return new ColumnWrapperImpl(column);
1920
}
2021

21-
private static class ColumnWrapperImpl implements ColumnWrapper {
22+
private static class ColumnWrapperImpl
23+
extends AbstractWrapper
24+
implements ColumnWrapper {
2225

2326
private Column wrappedColumn = null;
2427

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/ConfigurationWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.hibernate.tool.orm.jbt.api.wrp.SessionFactoryWrapper;
1818
import org.hibernate.tool.orm.jbt.api.wrp.TableWrapper;
1919
import org.hibernate.tool.orm.jbt.internal.util.ExtendedConfiguration;
20+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
2021
import org.hibernate.tool.orm.jbt.util.JpaConfiguration;
2122
import org.hibernate.tool.orm.jbt.util.NativeConfiguration;
2223
import org.hibernate.tool.orm.jbt.util.RevengConfiguration;
@@ -41,7 +42,9 @@ private static ConfigurationWrapper createConfigurationWrapper(final Configurati
4142
return new ConfigurationWrapperImpl(wrappedConfiguration);
4243
}
4344

44-
private static class ConfigurationWrapperImpl implements ConfigurationWrapper {
45+
private static class ConfigurationWrapperImpl
46+
extends AbstractWrapper
47+
implements ConfigurationWrapper {
4548

4649
private Configuration wrappedConfiguration = null;
4750

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/CriteriaWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.List;
44

55
import org.hibernate.tool.orm.jbt.api.wrp.CriteriaWrapper;
6+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
67

78
import jakarta.persistence.Query;
89

@@ -12,7 +13,9 @@ public static CriteriaWrapper createCriteriaWrapper(final Query wrappedCriteria)
1213
return new CriteriaWrapperImpl(wrappedCriteria);
1314
}
1415

15-
private static class CriteriaWrapperImpl implements CriteriaWrapper {
16+
private static class CriteriaWrapperImpl
17+
extends AbstractWrapper
18+
implements CriteriaWrapper {
1619

1720
private Query query = null;
1821

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/DatabaseReaderWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.hibernate.tool.orm.jbt.api.wrp.DatabaseReaderWrapper;
2424
import org.hibernate.tool.orm.jbt.api.wrp.RevengStrategyWrapper;
2525
import org.hibernate.tool.orm.jbt.api.wrp.TableWrapper;
26+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
2627

2728
public class DatabaseReaderWrapperFactory {
2829

@@ -32,7 +33,9 @@ public static DatabaseReaderWrapper createDatabaseReaderWrapper(
3233
return new DatabaseReaderWrapperImpl(properties, (RevengStrategy)revengStrategy.getWrappedObject());
3334
}
3435

35-
static class DatabaseReaderWrapperImpl implements DatabaseReaderWrapper {
36+
static class DatabaseReaderWrapperImpl
37+
extends AbstractWrapper
38+
implements DatabaseReaderWrapper {
3639

3740
DatabaseReader databaseReader = null;
3841
RevengMetadataCollector revengMetadataCollector = null;

jbt/src/main/java/org/hibernate/tool/orm/jbt/internal/factory/DdlExporterWrapperFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
import org.hibernate.tool.api.export.ExporterConstants;
66
import org.hibernate.tool.internal.export.ddl.DdlExporter;
77
import org.hibernate.tool.orm.jbt.api.wrp.DdlExporterWrapper;
8+
import org.hibernate.tool.orm.jbt.internal.wrp.AbstractWrapper;
89

910
public class DdlExporterWrapperFactory {
1011

1112
public static DdlExporterWrapper createDdlExporterWrapper(final DdlExporter wrappedDdlExporter) {
1213
return new DdlExporterWrapperImpl(wrappedDdlExporter);
1314
}
1415

15-
private static class DdlExporterWrapperImpl implements DdlExporterWrapper {
16+
private static class DdlExporterWrapperImpl
17+
extends AbstractWrapper
18+
implements DdlExporterWrapper {
1619

1720
private DdlExporter ddlExporter = null;
1821

0 commit comments

Comments
 (0)