No effective change - reformat code

This commit is contained in:
Robin Bygrave
2016-02-09 14:51:26 +13:00
parent 4272c17689
commit d2b048b0b4
18 changed files with 469 additions and 478 deletions
@@ -1,13 +1,12 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.PersistenceException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Types;
import javax.persistence.PersistenceException;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
/**
* Creates "Counter" GeneratedProperty for various types of number.
* <p>
@@ -16,49 +15,49 @@ import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
*/
public class CounterFactory {
final GeneratedCounterInteger integerCounter = new GeneratedCounterInteger();
final GeneratedCounterInteger integerCounter = new GeneratedCounterInteger();
final GeneratedCounterLong longCounter = new GeneratedCounterLong();
final GeneratedCounterLong longCounter = new GeneratedCounterLong();
public void setCounter(DeployBeanProperty property) {
public void setCounter(DeployBeanProperty property) {
property.setGeneratedProperty(createCounter(property));
}
/**
* Create the GeneratedProperty based on the property type.
*/
private GeneratedProperty createCounter(DeployBeanProperty property) {
Class<?> propType = property.getPropertyType();
if (propType.equals(Integer.class) || propType.equals(int.class)) {
return integerCounter;
}
if (propType.equals(Long.class) || propType.equals(long.class)) {
return longCounter;
}
int type = getType(propType);
return new GeneratedCounter(type);
}
private int getType(Class<?> propType){
if (propType.equals(Short.class) || propType.equals(short.class)){
return Types.TINYINT;
}
if (propType.equals(BigDecimal.class)){
return Types.DECIMAL;
}
if (propType.equals(Double.class) || propType.equals(double.class)){
return Types.DOUBLE;
}
if (propType.equals(Float.class) || propType.equals(float.class)){
return Types.REAL;
}
if (propType.equals(BigInteger.class)){
return Types.BIGINT;
}
String msg = "Can not support Counter for type "+propType.getName();
throw new PersistenceException(msg);
}
property.setGeneratedProperty(createCounter(property));
}
/**
* Create the GeneratedProperty based on the property type.
*/
private GeneratedProperty createCounter(DeployBeanProperty property) {
Class<?> propType = property.getPropertyType();
if (propType.equals(Integer.class) || propType.equals(int.class)) {
return integerCounter;
}
if (propType.equals(Long.class) || propType.equals(long.class)) {
return longCounter;
}
int type = getType(propType);
return new GeneratedCounter(type);
}
private int getType(Class<?> propType) {
if (propType.equals(Short.class) || propType.equals(short.class)) {
return Types.TINYINT;
}
if (propType.equals(BigDecimal.class)) {
return Types.DECIMAL;
}
if (propType.equals(Double.class) || propType.equals(double.class)) {
return Types.DOUBLE;
}
if (propType.equals(Float.class) || propType.equals(float.class)) {
return Types.REAL;
}
if (propType.equals(BigInteger.class)) {
return Types.BIGINT;
}
String msg = "Can not support Counter for type " + propType.getName();
throw new PersistenceException(msg);
}
}
@@ -9,51 +9,51 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class GeneratedCounter implements GeneratedProperty {
final int numberType;
final int numberType;
public GeneratedCounter(int numberType) {
this.numberType = numberType;
}
public GeneratedCounter(int numberType) {
this.numberType = numberType;
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return BasicTypeConverter.convert(1, numberType);
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return BasicTypeConverter.convert(1, numberType);
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Number currVal = (Number) prop.getValue(bean);
Integer nextVal = currVal.intValue() + 1;
return BasicTypeConverter.convert(nextVal, numberType);
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Number currVal = (Number) prop.getValue(bean);
Integer nextVal = currVal.intValue() + 1;
return BasicTypeConverter.convert(nextVal, numberType);
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -8,48 +8,48 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class GeneratedCounterInteger implements GeneratedProperty {
public GeneratedCounterInteger() {
public GeneratedCounterInteger() {
}
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return 1;
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return 1;
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Integer i = (Integer) prop.getValue(bean);
return i + 1;
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Integer i = (Integer) prop.getValue(bean);
return i + 1;
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -8,48 +8,48 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class GeneratedCounterLong implements GeneratedProperty {
public GeneratedCounterLong() {
public GeneratedCounterLong() {
}
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return (long) 1;
}
/**
* Always returns a 1.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return (long) 1;
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Long i = (Long) prop.getValue(bean);
return i + 1;
}
/**
* Increments the current value by one.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
Long i = (Long) prop.getValue(bean);
return i + 1;
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
/**
* Include this in every update.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Include this in every insert setting initial counter value to 1.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -1,52 +1,52 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import java.util.Date;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import java.util.Date;
/**
* Used to generate a (java.util.Date) timestamp when a bean is inserted.
*/
public class GeneratedInsertDate implements GeneratedProperty {
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -2,9 +2,8 @@ package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import org.joda.time.LocalDateTime;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
/**
* Support joda time types as GeneratedProperty.
@@ -8,43 +8,43 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class GeneratedInsertLong implements GeneratedProperty {
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -1,52 +1,52 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import java.sql.Timestamp;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import java.sql.Timestamp;
/**
* Used to generate a timestamp when a bean is inserted.
*/
public class GeneratedInsertTimestamp implements GeneratedProperty, GeneratedWhenCreated {
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* Return the current time as a Timestamp.
*/
@Override
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Just returns the beans original insert timestamp value.
*/
@Override
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return prop.getValue(bean);
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
/**
* Return false.
*/
public boolean includeInUpdate() {
return false;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return false;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Return true.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -9,39 +9,39 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public interface GeneratedProperty {
/**
* Get the generated insert value for a specific property of a bean.
*/
Object getInsertValue(BeanProperty prop, EntityBean bean, long now);
/**
* Get the generated insert value for a specific property of a bean.
*/
Object getInsertValue(BeanProperty prop, EntityBean bean, long now);
/**
* Get the generated update value for a specific property of a bean.
*/
Object getUpdateValue(BeanProperty prop, EntityBean bean, long now);
/**
* Get the generated update value for a specific property of a bean.
*/
Object getUpdateValue(BeanProperty prop, EntityBean bean, long now);
/**
* Return true if this should always be includes in an update statement.
* <p>
* Used to include GeneratedUpdateTimestamp in dynamic table updates.
* </p>
*/
boolean includeInUpdate();
/**
* Return true if the property should be included in an update even if
* it is not loaded (ie. Last Updated Timestamp).
*/
boolean includeInAllUpdates();
/**
* Return true if this should always be includes in an update statement.
* <p>
* Used to include GeneratedUpdateTimestamp in dynamic table updates.
* </p>
*/
boolean includeInUpdate();
/**
* Return true if this should be included in insert statements.
*/
boolean includeInInsert();
/**
* Return true if the property should be included in an update even if
* it is not loaded (ie. Last Updated Timestamp).
*/
boolean includeInAllUpdates();
/**
* Return true if the GeneratedProperty implies the DDL to create the DB
* column should have a not null constraint.
*/
boolean isDDLNotNullable();
/**
* Return true if this should be included in insert statements.
*/
boolean includeInInsert();
/**
* Return true if the GeneratedProperty implies the DDL to create the DB
* column should have a not null constraint.
*/
boolean isDDLNotNullable();
}
@@ -1,19 +1,19 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import java.math.BigDecimal;
import java.util.HashSet;
import com.avaje.ebean.config.ClassLoadConfig;
import com.avaje.ebean.config.CurrentUserProvider;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import java.math.BigDecimal;
import java.util.HashSet;
/**
* Default implementation of GeneratedPropertyFactory.
*/
public class GeneratedPropertyFactory {
private final CounterFactory counterFactory = new CounterFactory();
private final CounterFactory counterFactory = new CounterFactory();
private final InsertTimestampFactory insertFactory;
@@ -34,7 +34,7 @@ public class GeneratedPropertyFactory {
this.updateFactory = new UpdateTimestampFactory(classLoadConfig);
CurrentUserProvider currentUserProvider = serverConfig.getCurrentUserProvider();
if (currentUserProvider != null) {
if (currentUserProvider != null) {
generatedWhoCreated = new GeneratedWhoCreated(currentUserProvider);
generatedWhoModified = new GeneratedWhoModified(currentUserProvider);
} else {
@@ -42,47 +42,47 @@ public class GeneratedPropertyFactory {
generatedWhoModified = null;
}
numberTypes.add(Integer.class.getName());
numberTypes.add(int.class.getName());
numberTypes.add(Long.class.getName());
numberTypes.add(long.class.getName());
numberTypes.add(Short.class.getName());
numberTypes.add(short.class.getName());
numberTypes.add(Double.class.getName());
numberTypes.add(double.class.getName());
numberTypes.add(BigDecimal.class.getName());
}
numberTypes.add(Integer.class.getName());
numberTypes.add(int.class.getName());
numberTypes.add(Long.class.getName());
numberTypes.add(long.class.getName());
numberTypes.add(Short.class.getName());
numberTypes.add(short.class.getName());
numberTypes.add(Double.class.getName());
numberTypes.add(double.class.getName());
numberTypes.add(BigDecimal.class.getName());
}
public ClassLoadConfig getClassLoadConfig() {
return classLoadConfig;
}
private boolean isNumberType(String typeClassName) {
return numberTypes.contains(typeClassName);
}
public void setVersion(DeployBeanProperty property) {
if (isNumberType(property.getPropertyType().getName())) {
setCounter(property);
} else {
setUpdateTimestamp(property);
}
}
public void setCounter(DeployBeanProperty property) {
counterFactory.setCounter(property);
}
return numberTypes.contains(typeClassName);
}
public void setInsertTimestamp(DeployBeanProperty property) {
insertFactory.setInsertTimestamp(property);
}
public void setVersion(DeployBeanProperty property) {
if (isNumberType(property.getPropertyType().getName())) {
setCounter(property);
} else {
setUpdateTimestamp(property);
}
}
public void setUpdateTimestamp(DeployBeanProperty property) {
updateFactory.setUpdateTimestamp(property);
}
public void setCounter(DeployBeanProperty property) {
counterFactory.setCounter(property);
}
public void setInsertTimestamp(DeployBeanProperty property) {
insertFactory.setInsertTimestamp(property);
}
public void setUpdateTimestamp(DeployBeanProperty property) {
updateFactory.setUpdateTimestamp(property);
}
public void setWhoCreated(DeployBeanProperty property) {
if (generatedWhoCreated == null) {
@@ -1,51 +1,51 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import java.util.Date;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import java.util.Date;
/**
* Generate a (java.util.Date) Timestamp whenever the bean is inserted or
* updated.
*/
public class GeneratedUpdateDate implements GeneratedProperty {
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return new Date(now);
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -3,10 +3,6 @@ package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
/**
* Support java.time DateTime types as GeneratedProperty.
*/
@@ -2,9 +2,8 @@ package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import org.joda.time.LocalDateTime;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
/**
* Support java.time DateTime types as GeneratedProperty.
@@ -8,41 +8,41 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
*/
public class GeneratedUpdateLong implements GeneratedProperty {
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return now;
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -1,50 +1,50 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import java.sql.Timestamp;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import java.sql.Timestamp;
/**
* Generate a Timestamp whenever the bean is inserted or updated.
*/
public class GeneratedUpdateTimestamp implements GeneratedProperty, GeneratedWhenModified {
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* Return now as a Timestamp.
*/
public Object getInsertValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* Return now as a Timestamp.
*/
public Object getUpdateValue(BeanProperty prop, EntityBean bean, long now) {
return new Timestamp(now);
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
/**
* For dynamic table updates make sure this is included.
*/
public boolean includeInUpdate() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
@Override
public boolean includeInAllUpdates() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
/**
* Include this in every insert.
*/
public boolean includeInInsert() {
return true;
}
public boolean isDDLNotNullable() {
return true;
}
}
@@ -1,5 +1,9 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebean.config.ClassLoadConfig;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.PersistenceException;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
@@ -7,17 +11,12 @@ import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.PersistenceException;
import com.avaje.ebean.config.ClassLoadConfig;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
/**
* Helper for creating Insert timestamp GeneratedProperty objects.
*/
public class InsertTimestampFactory {
final GeneratedInsertLong longTime = new GeneratedInsertLong();
final GeneratedInsertLong longTime = new GeneratedInsertLong();
final Map<Class<?>, GeneratedProperty> map = new HashMap<Class<?>, GeneratedProperty>();
@@ -41,21 +40,21 @@ public class InsertTimestampFactory {
public void setInsertTimestamp(DeployBeanProperty property) {
property.setGeneratedProperty(createInsertTimestamp(property));
}
/**
* Create the insert GeneratedProperty depending on the property type.
*/
public GeneratedProperty createInsertTimestamp(DeployBeanProperty property) {
Class<?> propType = property.getPropertyType();
property.setGeneratedProperty(createInsertTimestamp(property));
}
/**
* Create the insert GeneratedProperty depending on the property type.
*/
public GeneratedProperty createInsertTimestamp(DeployBeanProperty property) {
Class<?> propType = property.getPropertyType();
GeneratedProperty generatedProperty = map.get(propType);
if (generatedProperty != null) {
return generatedProperty;
}
throw new PersistenceException("Generated Insert Timestamp not supported on "+propType.getName());
}
throw new PersistenceException("Generated Insert Timestamp not supported on " + propType.getName());
}
}
@@ -1,5 +1,9 @@
package com.avaje.ebeaninternal.server.deploy.generatedproperty;
import com.avaje.ebean.config.ClassLoadConfig;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.PersistenceException;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
@@ -7,17 +11,12 @@ import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.PersistenceException;
import com.avaje.ebean.config.ClassLoadConfig;
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
/**
* Helper for creating Update timestamp GeneratedProperty objects.
*/
public class UpdateTimestampFactory {
final GeneratedUpdateLong longTime = new GeneratedUpdateLong();
final GeneratedUpdateLong longTime = new GeneratedUpdateLong();
final Map<Class<?>, GeneratedProperty> map = new HashMap<Class<?>, GeneratedProperty>();
@@ -38,15 +37,15 @@ public class UpdateTimestampFactory {
}
}
public void setUpdateTimestamp(DeployBeanProperty property) {
public void setUpdateTimestamp(DeployBeanProperty property) {
property.setGeneratedProperty(createUpdateTimestamp(property));
}
/**
* Create the update GeneratedProperty depending on the property type.
*/
protected GeneratedProperty createUpdateTimestamp(DeployBeanProperty property) {
property.setGeneratedProperty(createUpdateTimestamp(property));
}
/**
* Create the update GeneratedProperty depending on the property type.
*/
protected GeneratedProperty createUpdateTimestamp(DeployBeanProperty property) {
Class<?> propType = property.getPropertyType();
GeneratedProperty generatedProperty = map.get(propType);
@@ -54,7 +53,7 @@ public class UpdateTimestampFactory {
return generatedProperty;
}
throw new PersistenceException("Generated update Timestamp not supported on "+propType.getName());
}
throw new PersistenceException("Generated update Timestamp not supported on " + propType.getName());
}
}
@@ -1,7 +1,7 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Counter, Insert Timestamp, Update Timestamp support</TITLE>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Counter, Insert Timestamp, Update Timestamp support</TITLE>
</HEAD>
<Body BGCOLOR="#ffffff">
Counter, Insert Timestamp, Update Timestamp support