#2318 - Refactor internals - final classes in deploy packages etc

This commit is contained in:
rbygrave committed 2021-08-17 19:00:55 +12:00
1 parent b4f4ef3c1b
commit 16a05528b7
93 files changed
+106 -182

No files matched your search

@@ -5,7 +5,7 @@ import io.ebeaninternal.server.query.SqlJoinType;
/**
* Helper for BeanPropertyAssocOne for OneToOne exported reference - not so common.
*/
class AssocOneHelpRefExported extends AssocOneHelp {
final class AssocOneHelpRefExported extends AssocOneHelp {
private final boolean softDelete;
@@ -9,7 +9,7 @@ import java.sql.SQLException;
/**
* Helper for BeanPropertyAssocOne imported reference but with inheritance.
*/
class AssocOneHelpRefInherit extends AssocOneHelp {
final class AssocOneHelpRefInherit extends AssocOneHelp {
private final InheritInfo inherit;
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.deploy;
/**
* Helper for BeanPropertyAssocOne imported reference - this is the common case.
*/
class AssocOneHelpRefSimple extends AssocOneHelp {
final class AssocOneHelpRefSimple extends AssocOneHelp {
AssocOneHelpRefSimple(BeanPropertyAssocOne<?> property, String embeddedPrefix) {
super(property, embeddedPrefix);
@@ -8,7 +8,7 @@ import javax.persistence.CascadeType;
* This is set to associated Beans, Table joins and List.
* </p>
*/
public class BeanCascadeInfo {
public final class BeanCascadeInfo {
private boolean delete;
@@ -11,16 +11,13 @@ import java.io.StringWriter;
/**
* Builds the 'new values' and 'old values' in JSON form for ChangeLog.
*/
class BeanChangeJson implements BeanDiffVisitor {
final class BeanChangeJson implements BeanDiffVisitor {
private final StringWriter newData;
private final StringWriter oldData;
private final SpiJsonWriter newJson;
private final SpiJsonWriter oldJson;
private final ArrayStack<BeanDescriptor<?>> stack = new ArrayStack<>();
private BeanDescriptor<?> descriptor;
BeanChangeJson(BeanDescriptor<?> descriptor, boolean statelessUpdate) {
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.query.CQueryCollectionAdd;
/**
* Creates Helpers specific to the type of the property (List Set or Map).
*/
public class BeanCollectionHelpFactory {
public final class BeanCollectionHelpFactory {
@SuppressWarnings("rawtypes")
private static final BeanListHelp LIST_HELP = new BeanListHelp();
@@ -21,7 +21,6 @@ public class BeanCollectionHelpFactory {
* Create the helper based on the many property.
*/
public static <T> BeanCollectionHelp<T> create(BeanPropertyAssocMany<T> many) {
boolean elementCollection = many.isElementCollection();
ManyType manyType = many.getManyType();
switch (manyType) {
@@ -30,7 +29,7 @@ public class BeanCollectionHelpFactory {
case SET:
return elementCollection ? new BeanSetHelpElement<>(many) : new BeanSetHelp<>(many);
case MAP:
return elementCollection ? new BeanMapHelpElement<>(many) :new BeanMapHelp<>(many);
return elementCollection ? new BeanMapHelpElement<>(many) : new BeanMapHelp<>(many);
default:
throw new RuntimeException("Invalid type " + manyType);
}
@@ -39,7 +38,6 @@ public class BeanCollectionHelpFactory {
@SuppressWarnings("unchecked")
public static <T> CQueryCollectionAdd<T> create(SpiQuery.Type manyType, OrmQueryRequest<T> request) {
if (manyType == SpiQuery.Type.LIST) {
return LIST_HELP;
@@ -56,5 +54,4 @@ public class BeanCollectionHelpFactory {
}
}
}
@@ -9,7 +9,7 @@ import java.util.Map;
/**
* Utility methods for BeanCollections.
*/
public class BeanCollectionUtil {
public final class BeanCollectionUtil {
/**
* Return true if this is a bean collection and not considered dirty.
@@ -66,7 +66,6 @@ public class BeanCollectionUtil {
// returns a collection of beans
return bc.getActualDetails();
}
if (o instanceof Map<?, ?>) {
// yes, we want the entrySet (to set the keys)
return ((Map<?, ?>) o).values();
@@ -16,10 +16,9 @@ import java.util.Map;
import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
class BeanDescriptorJsonHelp<T> {
final class BeanDescriptorJsonHelp<T> {
private final BeanDescriptor<T> desc;
private final InheritInfo inheritInfo;
BeanDescriptorJsonHelp(BeanDescriptor<T> desc) {
@@ -28,21 +27,16 @@ class BeanDescriptorJsonHelp<T> {
}
void jsonWrite(SpiJsonWriter writeJson, EntityBean bean, String key) throws IOException {
writeJson.writeStartObject(key);
if (inheritInfo == null) {
jsonWriteProperties(writeJson, bean);
} else {
InheritInfo localInheritInfo = inheritInfo.readType(bean.getClass());
String discValue = localInheritInfo.getDiscriminatorStringValue();
String discColumn = localInheritInfo.getDiscriminatorColumn();
writeJson.gen().writeStringField(discColumn, discValue);
localInheritInfo.desc().jsonWriteProperties(writeJson, bean);
}
writeJson.writeEndObject();
}
@@ -59,7 +53,6 @@ class BeanDescriptorJsonHelp<T> {
}
void jsonWriteDirtyProperties(SpiJsonWriter writeJson, EntityBean bean, boolean[] dirtyProps) throws IOException {
writeJson.writeStartObject(null);
// render the dirty properties
BeanProperty[] props = desc.propertiesNonTransient();
@@ -73,7 +66,6 @@ class BeanDescriptorJsonHelp<T> {
@SuppressWarnings("unchecked")
T jsonRead(SpiJsonReader jsonRead, String path, boolean withInheritance) throws IOException {
JsonParser parser = jsonRead.getParser();
//noinspection StatementWithEmptyBody
if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
@@ -115,21 +107,17 @@ class BeanDescriptorJsonHelp<T> {
}
private T jsonReadObject(SpiJsonReader readJson, String path) throws IOException {
EntityBean bean = desc.createEntityBeanForJson();
return jsonReadProperties(readJson, bean, path);
}
@SuppressWarnings("unchecked")
private T jsonReadProperties(SpiJsonReader readJson, EntityBean bean, String path) throws IOException {
if (path != null) {
readJson.pushPath(path);
}
// unmapped properties, send to JsonReadBeanVisitor later
Map<String, Object> unmappedProperties = null;
do {
JsonParser parser = readJson.getParser();
JsonToken event = parser.nextToken();
@@ -86,7 +86,7 @@ import java.util.concurrent.TimeUnit;
/**
* Creates BeanDescriptors.
*/
public class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTypeManager {
public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTypeManager {
private static final Logger logger = LoggerFactory.getLogger(BeanDescriptorManager.class);
@@ -1,7 +1,6 @@
package io.ebeaninternal.server.deploy;
public class BeanEmbeddedMeta {
public final class BeanEmbeddedMeta {
private final BeanProperty[] properties;
@@ -10,7 +10,7 @@ import java.util.Map;
* Creates BeanProperties for Embedded beans that have deployment information
* such as the actual DB column name and table alias.
*/
class BeanEmbeddedMetaFactory {
final class BeanEmbeddedMetaFactory {
/**
* Create BeanProperties for embedded beans using the deployment specific DB column name and table alias.
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Default implementation for BeanFinderFactory.
*/
class BeanFinderManager {
final class BeanFinderManager {
private final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
@@ -16,7 +16,6 @@ public final class BeanFkeyProperty implements ElPropertyValue {
private final String name;
private final String dbColumn;
private final boolean containsMany;
private final int deployOrder;
public BeanFkeyProperty(String name, String dbColumn, int deployOrder) {
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.core.PersistRequest;
/**
* Metrics for ORM Insert Update and Delete for a given bean type.
*/
class BeanIudMetrics {
final class BeanIudMetrics {
private final TimedMetric insert;
private final TimedMetric update;
@@ -21,7 +21,6 @@ class BeanIudMetrics {
* Create for a given bean type.
*/
BeanIudMetrics(String beanShortName) {
MetricFactory metricFactory = MetricFactory.get();
String prefix = "iud." + beanShortName;
this.insert = metricFactory.createTimedMetric(prefix + ".insert");
@@ -30,7 +30,7 @@ import java.util.List;
* lifecycle events.
* </p>
*/
class BeanLifecycleAdapterFactory {
final class BeanLifecycleAdapterFactory {
private final boolean postConstructPresent;
@@ -42,20 +42,16 @@ class BeanLifecycleAdapterFactory {
* Register a BeanPersistController for methods annotated with lifecycle events.
*/
void addLifecycleMethods(DeployBeanDescriptor<?> deployDesc) {
Method[] methods = deployDesc.getBeanType().getMethods();
// look for annotated methods
MethodsHolder methodHolder = new MethodsHolder();
for (Method m : methods) {
methodHolder.checkMethod(m, postConstructPresent);
}
if (methodHolder.hasPersistMethods()) {
// has pre/post persist annotated methods
deployDesc.addPersistController(new PersistAdapter(new PersistMethodsHolder(methodHolder)));
}
if (!methodHolder.postLoads.isEmpty()) {
// has postLoad methods
deployDesc.addPostLoad(new PostLoadAdapter(methodHolder.postLoads));
@@ -69,7 +65,7 @@ class BeanLifecycleAdapterFactory {
/**
* Holds Methods for the lifecycle events.s
*/
private static class MethodsHolder {
private static final class MethodsHolder {
private boolean hasPersistMethods;
private final List<Method> preInserts = new ArrayList<>();
@@ -162,7 +158,7 @@ class BeanLifecycleAdapterFactory {
/**
* Holds Methods for the lifecycle events.s
*/
private static class PersistMethodsHolder {
private static final class PersistMethodsHolder {
private final Method[] preInserts;
private final Method[] postInserts;
@@ -188,7 +184,7 @@ class BeanLifecycleAdapterFactory {
/**
* BeanPersistAdapter using reflection to invoke lifecycle methods.
*/
private static class PersistAdapter extends BeanPersistAdapter {
private static final class PersistAdapter extends BeanPersistAdapter {
private final PersistMethodsHolder methodHolder;
@@ -264,7 +260,7 @@ class BeanLifecycleAdapterFactory {
/**
* BeanPostLoad using reflection to invoke lifecycle methods.
*/
private static class PostLoadAdapter implements BeanPostLoad {
private static final class PostLoadAdapter implements BeanPostLoad {
private final Method[] postLoadMethods;
@@ -297,7 +293,7 @@ class BeanLifecycleAdapterFactory {
/**
* PostConstructAdapter using reflection to invoke lifecycle methods.
*/
private static class PostConstructAdapter implements BeanPostConstructListener {
private static final class PostConstructAdapter implements BeanPostConstructListener {
private final Method[] postConstructMethods;
@@ -7,7 +7,7 @@ import io.ebeaninternal.api.json.SpiJsonWriter;
/**
* Helper for element collection List.
*/
public class BeanListHelpElement<T> extends BeanListHelp<T> {
public final class BeanListHelpElement<T> extends BeanListHelp<T> {
BeanListHelpElement(BeanPropertyAssocMany<T> many) {
super(many);
@@ -5,10 +5,9 @@ import io.ebeaninternal.server.persist.BeanPersister;
/**
* Holds the BeanDescriptor and its associated BeanPersister.
*/
public class BeanManager<T> {
public final class BeanManager<T> {
private final BeanPersister persister;
private final BeanDescriptor<T> descriptor;
public BeanManager(BeanDescriptor<T> descriptor, BeanPersister persister) {
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.persist.dml.DmlBeanPersisterFactory;
/**
* Creates BeanManagers.
*/
class BeanManagerFactory {
final class BeanManagerFactory {
private final BeanPersisterFactory persisterFactory;
@@ -5,7 +5,7 @@ import io.ebean.bean.EntityBean;
import io.ebean.common.BeanMap;
import io.ebeaninternal.api.json.SpiJsonWriter;
public class BeanMapHelpElement<T> extends BeanMapHelp<T> {
public final class BeanMapHelpElement<T> extends BeanMapHelp<T> {
BeanMapHelpElement(BeanPropertyAssocMany<T> many) {
super(many);
@@ -6,7 +6,7 @@ import io.ebean.common.BeanMap;
import io.ebeaninternal.server.el.ElPropertyValue;
import io.ebeaninternal.server.query.CQueryCollectionAdd;
class BeanMapQueryHelp<T> implements CQueryCollectionAdd<T> {
final class BeanMapQueryHelp<T> implements CQueryCollectionAdd<T> {
private final ElPropertyValue elGetValue;
@@ -6,7 +6,7 @@ import java.util.Set;
/**
* Natural key for a bean type.
*/
public class BeanNaturalKey {
public final class BeanNaturalKey {
private final String[] naturalKey;
private final BeanProperty[] props;
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
/**
* Bean property for an IdClass embeddedId.
*/
public class BeanPropertyIdClass extends BeanPropertyAssocOne {
public final class BeanPropertyIdClass extends BeanPropertyAssocOne {
@SuppressWarnings("unchecked")
public BeanPropertyIdClass(BeanDescriptorMap owner, BeanDescriptor descriptor, DeployBeanPropertyAssocOne deploy) {
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
*
* The value of which is held on the entity bean intercept.
*/
public class BeanPropertyOrderColumn extends BeanProperty {
public final class BeanPropertyOrderColumn extends BeanProperty {
public BeanPropertyOrderColumn(BeanDescriptor<?> descriptor, DeployBeanProperty deploy) {
super(descriptor, deploy);
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.core.InternString;
* Typically this is for Embedded Beans.
* </p>
*/
class BeanPropertyOverride {
final class BeanPropertyOverride {
private final String dbColumn;
private final boolean dbNullable;
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertySimpleCollection;
import java.io.IOException;
public class BeanPropertySimpleCollection<T> extends BeanPropertyAssocMany<T> {
public final class BeanPropertySimpleCollection<T> extends BeanPropertyAssocMany<T> {
public BeanPropertySimpleCollection(BeanDescriptor<?> descriptor, DeployBeanPropertySimpleCollection<T> deploy) {
super(descriptor, deploy);
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
class BeanQueryAdapterManager {
final class BeanQueryAdapterManager {
private static final Logger logger = LoggerFactory.getLogger(BeanQueryAdapterManager.class);
@@ -7,7 +7,7 @@ import io.ebeaninternal.api.json.SpiJsonWriter;
/**
* Helper for element collection List.
*/
public class BeanSetHelpElement<T> extends BeanSetHelp<T> {
public final class BeanSetHelpElement<T> extends BeanSetHelp<T> {
BeanSetHelpElement(BeanPropertyAssocMany<T> many) {
super(many);
@@ -17,19 +17,13 @@ import org.slf4j.LoggerFactory;
* in a BeanDescriptor.
* </p>
*/
public class BeanTable {
public final class BeanTable {
private static final Logger logger = LoggerFactory.getLogger(BeanTable.class);
private final BeanDescriptorMap owner;
private final Class<?> beanType;
/**
* The base table.
*/
private final String baseTable;
private final BeanProperty idProperty;
/**
@@ -14,7 +14,7 @@ import java.util.List;
* <p>
* Used when multiple BeanPersistController register for the same bean type.
*/
public class ChainedBeanPersistController implements BeanPersistController {
public final class ChainedBeanPersistController implements BeanPersistController {
private static final Sorter SORTER = new Sorter();
@@ -9,10 +9,9 @@ import java.util.Set;
/**
* Handles multiple BeanPersistListener's for a given entity type.
*/
public class ChainedBeanPersistListener implements BeanPersistListener {
public final class ChainedBeanPersistListener implements BeanPersistListener {
private final List<BeanPersistListener> list;
private final BeanPersistListener[] chain;
/**
@@ -8,10 +8,9 @@ import java.util.List;
/**
* Handles multiple BeanPostLoad's for a given entity type.
*/
public class ChainedBeanPostConstructListener implements BeanPostConstructListener {
public final class ChainedBeanPostConstructListener implements BeanPostConstructListener {
private final List<BeanPostConstructListener> list;
private final BeanPostConstructListener[] chain;
/**
@@ -8,10 +8,9 @@ import java.util.List;
/**
* Handles multiple BeanPostLoad's for a given entity type.
*/
public class ChainedBeanPostLoad implements BeanPostLoad {
public final class ChainedBeanPostLoad implements BeanPostLoad {
private final List<BeanPostLoad> list;
private final BeanPostLoad[] chain;
/**
@@ -11,12 +11,11 @@ import java.util.List;
/**
* Handles multiple BeanQueryAdapter for a given entity type.
*/
public class ChainedBeanQueryAdapter implements BeanQueryAdapter {
public final class ChainedBeanQueryAdapter implements BeanQueryAdapter {
private static final Sorter SORTER = new Sorter();
private final List<BeanQueryAdapter> list;
private final BeanQueryAdapter[] chain;
/**
@@ -6,7 +6,7 @@ import io.ebeaninternal.api.SpiCacheRegion;
/**
* Default implementation of SpiCacheControl.
*/
class DCacheControl implements SpiCacheControl {
final class DCacheControl implements SpiCacheControl {
private final SpiCacheRegion region;
private final boolean bean;
@@ -5,7 +5,7 @@ import io.ebeaninternal.api.SpiCacheControl;
/**
* Cache control used when no caching is on the bean type.
*/
class DCacheControlNone implements SpiCacheControl {
final class DCacheControlNone implements SpiCacheControl {
static final SpiCacheControl INSTANCE = new DCacheControlNone();
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy;
import io.ebeaninternal.api.SpiCacheRegion;
public class DCacheRegion implements SpiCacheRegion {
public final class DCacheRegion implements SpiCacheRegion {
private boolean enabled = true;
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy;
import io.ebeaninternal.api.SpiCacheRegion;
class DCacheRegionNone implements SpiCacheRegion {
final class DCacheRegionNone implements SpiCacheRegion {
static final SpiCacheRegion INSTANCE = new DCacheRegionNone();
@@ -10,7 +10,7 @@ import io.ebean.annotation.Platform;
*
* @author Roland Praml, FOCONIS AG
*/
public class DbMigrationInfo {
public final class DbMigrationInfo {
private final List<String> preAdd;
private final List<String> postAdd;
@@ -8,7 +8,7 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyOptions;
/**
* The options for document property collected when reading deployment mapping.
*/
public class DeployDocPropertyOptions {
public final class DeployDocPropertyOptions {
private static final DocPropertyOptions EMPTY = new DocPropertyOptions();
@@ -24,7 +24,6 @@ public class DeployDocPropertyOptions {
* Read the DocProperty deployment options.
*/
public void setDocProperty(DocProperty doc) {
createOptions();
mapping.apply(doc);
}
@@ -33,7 +32,6 @@ public class DeployDocPropertyOptions {
* Read the DocSortable deployment options.
*/
public void setDocSortable(DocSortable doc) {
createOptions();
mapping.setSortable(true);
setStore(doc.store());
@@ -45,7 +43,6 @@ public class DeployDocPropertyOptions {
* Read the DocCode deployment options.
*/
public void setDocCode(DocCode doc) {
createOptions();
mapping.setCode(true);
setStore(doc.store());
@@ -5,7 +5,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocMany;
import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
class DetermineAggPath {
final class DetermineAggPath {
/**
* Return the many path for the given aggregation formula.
@@ -7,10 +7,7 @@ import java.util.Set;
/**
* Determine the Many Type for a property.
*/
public class DetermineManyType {
public DetermineManyType() {
}
public final class DetermineManyType {
public ManyType getManyType(Class<?> type) {
if (type.equals(List.class)) {
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy;
import io.ebeaninternal.server.query.SqlBeanLoad;
public class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyAggregationFormula {
public final class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyAggregationFormula {
private final BeanPropertyAssocOne prop;
@@ -3,14 +3,12 @@ package io.ebeaninternal.server.deploy;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
class ElementEntityBean implements EntityBean {
final class ElementEntityBean implements EntityBean {
private static final long serialVersionUID = 8742536671024715601L;
private final String[] properties;
private Object[] data;
private final EntityBeanIntercept intercept;
ElementEntityBean(String[] properties) {
@@ -6,7 +6,7 @@ import io.ebean.common.BeanList;
import java.util.ArrayList;
import java.util.List;
class ElementHelpList implements ElementHelp {
final class ElementHelpList implements ElementHelp {
@Override
public ElementCollector createCollector() {
@@ -6,7 +6,7 @@ import io.ebean.common.BeanMap;
import java.util.LinkedHashMap;
import java.util.Map;
class ElementHelpMap implements ElementHelp {
final class ElementHelpMap implements ElementHelp {
@Override
public ElementCollector createCollector() {
@@ -6,7 +6,7 @@ import io.ebean.common.BeanSet;
import java.util.LinkedHashSet;
import java.util.Set;
class ElementHelpSet implements ElementHelp {
final class ElementHelpSet implements ElementHelp {
@Override
public ElementCollector createCollector() {
@@ -9,12 +9,10 @@ import io.ebeaninternal.server.core.InternString;
* Used to for Assoc Manys to create references etc.
* </p>
*/
class ExportedProperty {
final class ExportedProperty {
private final String foreignDbColumn;
private final BeanProperty property;
private final boolean embedded;
ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
@@ -4,7 +4,7 @@ import io.ebean.annotation.IdentityGenerated;
import io.ebean.config.dbplatform.IdType;
import io.ebeaninternal.server.deploy.meta.DeployIdentityMode;
public class IdentityMode {
public final class IdentityMode {
public static IdentityMode NONE = new IdentityMode();
@@ -5,7 +5,7 @@ import io.ebean.annotation.Platform;
/**
* Holds multiple column unique constraints defined for an entity.
*/
public class IndexDefinition {
public final class IndexDefinition {
private final String[] columns;
private final String name;
@@ -17,43 +17,30 @@ import java.util.Set;
/**
* Represents a node in the Inheritance tree. Holds information regarding Super Subclass support.
*/
public class InheritInfo {
public final class InheritInfo {
private final String discriminatorStringValue;
private final Object discriminatorValue;
private final String discriminatorColumn;
private final int discriminatorType;
private final int discriminatorLength;
private final String columnDefn;
private final String where;
private final Class<?> type;
private final List<InheritInfo> children = new ArrayList<>();
/**
* Map of discriminator values to InheritInfo.
*/
private final HashMap<String, InheritInfo> discMap;
/**
* Map of class types to InheritInfo (taking into account subclass proxy classes).
*/
private final HashMap<String, InheritInfo> typeMap;
private final InheritInfo parent;
private final InheritInfo root;
private BeanDescriptor<?> descriptor;
public InheritInfo(InheritInfo r, InheritInfo parent, DeployInheritInfo deploy) {
this.parent = parent;
this.type = deploy.getType();
this.discriminatorColumn = InternString.intern(deploy.getColumnName(parent));
@@ -85,7 +72,6 @@ public class InheritInfo {
* Visit all the children in the inheritance tree.
*/
public void visitChildren(InheritInfoVisitor visitor) {
for (InheritInfo child : children) {
visitor.visit(child);
child.visitChildren(visitor);
@@ -96,7 +82,6 @@ public class InheritInfo {
* Append check constraint values for the entire inheritance hierarchy.
*/
public void appendCheckConstraintValues(final String propertyName, final Set<String> checkConstraintValues) {
visitChildren(inheritInfo -> {
BeanProperty prop = inheritInfo.desc().getBeanProperty(propertyName);
if (prop != null) {
@@ -190,9 +175,7 @@ public class InheritInfo {
* Get the bean property additionally looking in the sub types.
*/
BeanProperty findSubTypeProperty(String propertyName) {
BeanProperty prop;
for (InheritInfo childInfo : children) {
// recursively search this child bean descriptor
prop = childInfo.desc().findProperty(propertyName);
@@ -200,7 +183,6 @@ public class InheritInfo {
return prop;
}
}
return null;
}
@@ -208,7 +190,6 @@ public class InheritInfo {
* Add the local properties for each sub class below this one.
*/
public void addChildrenProperties(SqlTreeProperties selectProps) {
for (InheritInfo childInfo : children) {
selectProps.add(childInfo.descriptor.propertiesLocal());
childInfo.addChildrenProperties(selectProps);
@@ -226,11 +207,9 @@ public class InheritInfo {
* Return the associated InheritInfo for this discriminator value.
*/
InheritInfo readType(String discValue) {
if (discValue == null) {
return null;
}
InheritInfo typeInfo = root.getType(discValue);
if (typeInfo == null) {
throw new PersistenceException("Inheritance type for discriminator value [" + discValue + "] was not found?");
@@ -242,7 +221,6 @@ public class InheritInfo {
* Return the associated InheritInfo for this bean type.
*/
public InheritInfo readType(Class<?> beanType) {
InheritInfo typeInfo = root.getTypeByClass(beanType);
if (typeInfo == null) {
throw new PersistenceException("Inheritance type for bean type [" + beanType.getName() + "] was not found?");
@@ -6,7 +6,7 @@ import java.util.List;
/**
* Helper to build IntersectionTable.
*/
public class IntersectionBuilder {
public final class IntersectionBuilder {
private final String publishTable;
private final String draftTable;
@@ -12,14 +12,11 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class IntersectionRow {
public final class IntersectionRow {
private final String tableName;
private final BeanDescriptor<?> targetDescriptor;
private final LinkedHashMap<String, Object> values = new LinkedHashMap<>();
private List<Object> excludeIds;
private BeanDescriptor<?> excludeDescriptor;
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.deploy;
import io.ebean.Database;
import io.ebean.SqlUpdate;
public class IntersectionTable {
public final class IntersectionTable {
private final String insertSql;
private final String deleteSql;
@@ -2,10 +2,9 @@ package io.ebeaninternal.server.deploy;
import io.ebean.annotation.PartitionMode;
public class PartitionMeta {
public final class PartitionMeta {
private final PartitionMode mode;
private String property;
public PartitionMeta(PartitionMode mode, String property) {
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
class PersistControllerManager {
final class PersistControllerManager {
private static final Logger logger = LoggerFactory.getLogger(PersistControllerManager.class);
@@ -12,7 +12,7 @@ import java.util.List;
* Manages the assignment/registration of BeanPersistListener with their
* respective DeployBeanDescriptor's.
*/
class PersistListenerManager {
final class PersistListenerManager {
private static final Logger logger = LoggerFactory.getLogger(PersistListenerManager.class);
@@ -5,7 +5,7 @@ import javax.persistence.Entity;
/**
* Utility to find the root bean type.
*/
public class PersistenceContextUtil {
public final class PersistenceContextUtil {
/**
* Find and return the root bean type for the given class.
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
class PostConstructManager {
final class PostConstructManager {
private static final Logger logger = LoggerFactory.getLogger(PostConstructManager.class);
@@ -11,7 +11,7 @@ import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
class PostLoadManager {
final class PostLoadManager {
private static final Logger logger = LoggerFactory.getLogger(PostLoadManager.class);
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.deploy;
import io.ebean.annotation.ConstraintMode;
import io.ebean.annotation.DbForeignKey;
public class PropertyForeignKey {
public final class PropertyForeignKey {
private final boolean noIndex;
private final boolean noConstraint;
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn;
/**
* A join pair of local and foreign properties.
*/
public class TableJoinColumn {
public final class TableJoinColumn {
/**
* The local database column name.
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.properties.BeanPropertySetter;
/**
* Setter used for "element beans" with ElementCollection.
*/
class BeanPropertyElementSetter implements BeanPropertySetter {
final class BeanPropertyElementSetter implements BeanPropertySetter {
private final int pos;
@@ -10,7 +10,7 @@ import java.util.Map;
* Typically collects the overridden column names mapped
* to the Embedded bean.
*/
public class DeployBeanEmbedded {
public final class DeployBeanEmbedded {
/**
* A map of property names to dbColumns.
@@ -8,7 +8,7 @@ import io.ebean.config.DatabaseConfig;
/**
* Used to obtain the Jackson AnnotatedClass for a given bean type utlimately to obtain field level Jackson annotations.
*/
class DeployBeanObtainJackson<T> {
final class DeployBeanObtainJackson<T> {
private final DatabaseConfig config;
private final Class<T> beanType;
@@ -7,7 +7,7 @@ import javax.persistence.CascadeType;
/**
* Property mapped to a joined bean.
*/
public class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
public final class DeployBeanPropertyAssocOne<T> extends DeployBeanPropertyAssoc<T> {
private boolean oneToOne;
@@ -15,7 +15,7 @@ import java.util.List;
/**
* Helper object to classify BeanProperties into appropriate lists.
*/
public class DeployBeanPropertyLists {
public final class DeployBeanPropertyLists {
private static final Logger logger = LoggerFactory.getLogger(DeployBeanPropertyLists.class);
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.deploy.meta;
import io.ebean.bean.BeanCollection.ModifyListenMode;
import io.ebeaninternal.server.deploy.ManyType;
public class DeployBeanPropertySimpleCollection<T> extends DeployBeanPropertyAssocMany<T> {
public final class DeployBeanPropertySimpleCollection<T> extends DeployBeanPropertyAssocMany<T> {
public DeployBeanPropertySimpleCollection(DeployBeanDescriptor<?> desc, Class<T> targetType, ManyType manyType) {
super(desc, targetType, manyType);
@@ -13,7 +13,7 @@ import io.ebeaninternal.server.deploy.BeanPropertyAssocOne;
* in a BeanDescriptor.
* </p>
*/
public class DeployBeanTable {
public final class DeployBeanTable {
private final Class<?> beanType;
@@ -5,7 +5,7 @@ import io.ebean.annotation.IdentityGenerated;
import io.ebean.annotation.IdentityType;
import io.ebean.config.dbplatform.IdType;
public class DeployIdentityMode {
public final class DeployIdentityMode {
public static DeployIdentityMode auto() {
return new DeployIdentityMode(IdType.AUTO);
@@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy.meta;
import javax.persistence.OrderColumn;
public class DeployOrderColumn {
public final class DeployOrderColumn {
/**
* Logical property name used for order by and available for expression language.
@@ -15,7 +15,7 @@ import java.util.Set;
* This gets converted into a immutable TableJoin when complete.
* </p>
*/
public class DeployTableJoin {
public final class DeployTableJoin {
/**
* The joined table.
@@ -33,7 +33,7 @@ public class DeployTableJoin {
private ArrayList<DeployTableJoinColumn> columns = new ArrayList<>(4);
private InheritInfo inheritInfo;
private String extraWhere;
/**
@@ -146,11 +146,11 @@ public class DeployTableJoin {
public String getExtraWhere() {
return extraWhere;
}
public void setExtraWhere(String extraWhere) {
this.extraWhere = extraWhere;
}
public DeployTableJoin createInverse(String tableName) {
DeployTableJoin inverse = new DeployTableJoin();
@@ -8,7 +8,7 @@ import javax.persistence.JoinColumn;
/**
* A join pair of local and foreign properties.
*/
public class DeployTableJoinColumn {
public final class DeployTableJoinColumn {
/**
* The local database column name.
@@ -41,7 +41,7 @@ import java.util.Set;
/**
* Read the deployment annotation for Assoc Many beans.
*/
class AnnotationAssocManys extends AnnotationAssoc {
final class AnnotationAssocManys extends AnnotationAssoc {
AnnotationAssocManys(DeployBeanInfo<?> info, ReadAnnotationConfig readConfig, BeanDescriptorManager factory) {
super(info, readConfig, factory);
@@ -30,7 +30,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
/**
* Read the deployment annotations for Associated One beans.
*/
public class AnnotationAssocOnes extends AnnotationAssoc {
final class AnnotationAssocOnes extends AnnotationAssoc {
private static final Logger log = LoggerFactory.getLogger(AnnotationAssocOnes.class);
@@ -36,7 +36,7 @@ import static io.ebean.util.AnnotationUtil.typeGet;
/**
* Read the class level deployment annotations.
*/
public class AnnotationClass extends AnnotationParser {
final class AnnotationClass extends AnnotationParser {
private static final Logger logger = LoggerFactory.getLogger(AnnotationClass.class);
@@ -76,7 +76,7 @@ import java.util.UUID;
/**
* Read the field level deployment annotations.
*/
public class AnnotationFields extends AnnotationParser {
final class AnnotationFields extends AnnotationParser {
/**
* If present read Jackson JsonIgnore.
@@ -15,7 +15,7 @@ import java.util.Set;
import static io.ebean.util.AnnotationUtil.get;
public class AnnotationFind {
final class AnnotationFind {
public static Set<JoinColumn> joinColumns(Field field) {
final JoinColumn col = get(field, JoinColumn.class);
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
/**
* Read the class level deployment annotations.
*/
class AnnotationSql extends AnnotationParser {
final class AnnotationSql extends AnnotationParser {
AnnotationSql(DeployBeanInfo<?> info, ReadAnnotationConfig readConfig) {
super(info, readConfig);
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.rawsql.SpiRawSql;
/**
* Wraps information about a bean during deployment parsing.
*/
public class DeployBeanInfo<T> {
public final class DeployBeanInfo<T> {
private final DeployUtil util;
@@ -35,7 +35,7 @@ import java.lang.reflect.WildcardType;
* one or normal scalar property.
* </p>
*/
public class DeployCreateProperties {
public final class DeployCreateProperties {
private static final Logger logger = LoggerFactory.getLogger(DeployCreateProperties.class);
@@ -15,7 +15,7 @@ import java.util.Map;
/**
* Builds the InheritInfo deployment information.
*/
public class DeployInherit {
public final class DeployInherit {
private final Map<Class<?>, DeployInheritInfo> deployMap = new LinkedHashMap<>();
@@ -12,7 +12,7 @@ import java.util.List;
* Represents a node in the Inheritance tree.
* Holds information regarding Super Subclass support.
*/
public class DeployInheritInfo {
public final class DeployInheritInfo {
/**
* the default discriminator column according to the JPA 1.0 spec.
@@ -26,7 +26,7 @@ import java.sql.Types;
/**
* Utility object to help processing deployment information.
*/
public class DeployUtil {
public final class DeployUtil {
/**
* Assumes CLOB rather than LONGVARCHAR.
@@ -1,6 +1,6 @@
package io.ebeaninternal.server.deploy.parse;
class InitMetaJacksonAnnotation {
final class InitMetaJacksonAnnotation {
static void init(ReadAnnotationConfig readConfig) {
readConfig.addMetaAnnotation(com.fasterxml.jackson.annotation.JacksonAnnotation.class);
@@ -15,7 +15,7 @@ import java.util.Set;
/**
* Configuration used when reading the deployment annotations.
*/
class ReadAnnotationConfig {
final class ReadAnnotationConfig {
private final GeneratedPropertyFactory generatedPropFactory;
private final String asOfViewSuffix;
@@ -8,7 +8,7 @@ import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory
/**
* Read the deployment annotations for the bean.
*/
public class ReadAnnotations {
public final class ReadAnnotations {
private final ReadAnnotationConfig readConfig;
@@ -12,7 +12,7 @@ import java.util.List;
/**
* Jakarta validation annotations reader.
*/
class ReadValidationAnnotationsJakarta implements ReadValidationAnnotations {
final class ReadValidationAnnotationsJakarta implements ReadValidationAnnotations {
ReadValidationAnnotationsJakarta(ReadAnnotationConfig readConfig) {
readConfig.addMetaAnnotation(Size.class);
@@ -12,7 +12,7 @@ import java.util.List;
/**
* Javax validation annotations reader.
*/
class ReadValidationAnnotationsJavax implements ReadValidationAnnotations {
final class ReadValidationAnnotationsJavax implements ReadValidationAnnotations {
ReadValidationAnnotationsJavax(ReadAnnotationConfig readConfig) {
readConfig.addMetaAnnotation(Size.class);
@@ -8,28 +8,22 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
/**
* Mark transient properties.
*/
public class TransientProperties {
public TransientProperties() {
}
public final class TransientProperties {
/**
* Mark any additional properties as transient.
*/
public void process(DeployBeanDescriptor<?> desc) {
for (DeployBeanProperty prop : desc.propertiesBase()) {
if (!prop.isDbRead() && !prop.isDbInsertable() && !prop.isDbUpdateable()) {
prop.setTransient();
}
}
for (DeployBeanPropertyAssocOne<?> prop : desc.propertiesAssocOne()) {
if (prop.getBeanTable() == null && !prop.isEmbedded()) {
prop.setTransient();
}
}
for (DeployBeanPropertyAssocMany<?> prop : desc.propertiesAssocMany()) {
if (prop.getBeanTable() == null) {
prop.setTransient();
@@ -11,7 +11,7 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
final class DRawSqlService implements SpiRawSqlService {
public final class DRawSqlService implements SpiRawSqlService {
@Override
public RawSql resultSet(ResultSet resultSet, String... propertyNames) {
@@ -7,7 +7,7 @@ import java.util.List;
/**
* Stack based on ArrayList.
*/
public final class ArrayStack<E> {
public class ArrayStack<E> {
private final List<E> list;
@@ -1,12 +1,16 @@
package io.ebeaninternal.server.deploy.parse;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.ServerConfig;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory;
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
import io.ebeaninternal.server.type.DefaultTypeManager;
import org.junit.Test;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -46,9 +50,8 @@ public class AnnotationClassTest {
DeployUtil deployUtil = new DeployUtil(new DefaultTypeManager(config, new BootupClasses()), config);
DeployBeanInfo deployBeanInfo = new DeployBeanInfo(deployUtil, mock(DeployBeanDescriptor.class));
ReadAnnotationConfig readAnnotationConfig = mock(ReadAnnotationConfig.class);
DeployBeanInfo deployBeanInfo = new DeployBeanInfo(deployUtil, new DeployBeanDescriptor<>(null, null, null));
ReadAnnotationConfig readAnnotationConfig = new ReadAnnotationConfig(new GeneratedPropertyFactory(true, new DatabaseConfig(), Collections.emptyList()), "","", new DatabaseConfig());
return new AnnotationClass(deployBeanInfo, readAnnotationConfig);
}