mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2318 - Refactor internals - trim whitespace in deploy package
This commit is contained in:
-1
@@ -16,7 +16,6 @@ import java.sql.Types;
|
||||
final class CounterFactory {
|
||||
|
||||
private final GeneratedCounterInteger integerCounter = new GeneratedCounterInteger();
|
||||
|
||||
private final GeneratedCounterLong longCounter = new GeneratedCounterLong();
|
||||
|
||||
void setCounter(DeployBeanProperty property) {
|
||||
|
||||
-1
@@ -61,5 +61,4 @@ final class GeneratedInsertJodaTime {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-7
@@ -45,7 +45,6 @@ public final class GeneratedPropertyFactory {
|
||||
generatedWhoCreated = null;
|
||||
generatedWhoModified = null;
|
||||
}
|
||||
|
||||
numberTypes.add(Integer.class.getName());
|
||||
numberTypes.add(int.class.getName());
|
||||
numberTypes.add(Long.class.getName());
|
||||
@@ -55,7 +54,6 @@ public final class GeneratedPropertyFactory {
|
||||
numberTypes.add(Double.class.getName());
|
||||
numberTypes.add(double.class.getName());
|
||||
numberTypes.add(BigDecimal.class.getName());
|
||||
|
||||
if (idGenerators != null) {
|
||||
for (IdGenerator idGenerator : idGenerators) {
|
||||
idGeneratorMap.put(idGenerator.getName(), new CustomIdGenerator(idGenerator));
|
||||
@@ -80,17 +78,14 @@ public final class GeneratedPropertyFactory {
|
||||
}
|
||||
|
||||
private void setCounter(DeployBeanProperty property) {
|
||||
|
||||
counterFactory.setCounter(property);
|
||||
}
|
||||
|
||||
public void setInsertTimestamp(DeployBeanProperty property) {
|
||||
|
||||
insertFactory.setInsertTimestamp(property);
|
||||
}
|
||||
|
||||
public void setUpdateTimestamp(DeployBeanProperty property) {
|
||||
|
||||
updateFactory.setUpdateTimestamp(property);
|
||||
}
|
||||
|
||||
@@ -122,7 +117,7 @@ public final class GeneratedPropertyFactory {
|
||||
/**
|
||||
* Wraps the custom IdGenerator to implement PlatformIdGenerator.
|
||||
*/
|
||||
private static class CustomIdGenerator implements PlatformIdGenerator {
|
||||
private static final class CustomIdGenerator implements PlatformIdGenerator {
|
||||
|
||||
private final IdGenerator generator;
|
||||
|
||||
@@ -151,7 +146,7 @@ public final class GeneratedPropertyFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static class DummyCurrentUser implements CurrentUserProvider {
|
||||
private static final class DummyCurrentUser implements CurrentUserProvider {
|
||||
@Override
|
||||
public Object currentUser() {
|
||||
throw new RuntimeException("never called");
|
||||
|
||||
-4
@@ -25,7 +25,6 @@ final class InsertTimestampFactory {
|
||||
GeneratedInsertLong longTime = new GeneratedInsertLong();
|
||||
map.put(Long.class, longTime);
|
||||
map.put(long.class, longTime);
|
||||
|
||||
map.put(Instant.class, new GeneratedInsertJavaTime.InstantDT());
|
||||
map.put(LocalDateTime.class, new GeneratedInsertJavaTime.LocalDT());
|
||||
map.put(OffsetDateTime.class, new GeneratedInsertJavaTime.OffsetDT());
|
||||
@@ -37,7 +36,6 @@ final class InsertTimestampFactory {
|
||||
}
|
||||
|
||||
void setInsertTimestamp(DeployBeanProperty property) {
|
||||
|
||||
property.setGeneratedProperty(createInsertTimestamp(property));
|
||||
}
|
||||
|
||||
@@ -45,13 +43,11 @@ final class InsertTimestampFactory {
|
||||
* Create the insert GeneratedProperty depending on the property type.
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
-5
@@ -25,12 +25,10 @@ final class UpdateTimestampFactory {
|
||||
GeneratedUpdateLong longTime = new GeneratedUpdateLong();
|
||||
map.put(Long.class, longTime);
|
||||
map.put(long.class, longTime);
|
||||
|
||||
map.put(Instant.class, new GeneratedUpdateJavaTime.InstantDT());
|
||||
map.put(LocalDateTime.class, new GeneratedUpdateJavaTime.LocalDT());
|
||||
map.put(OffsetDateTime.class, new GeneratedUpdateJavaTime.OffsetDT());
|
||||
map.put(ZonedDateTime.class, new GeneratedUpdateJavaTime.ZonedDT());
|
||||
|
||||
if (classLoadConfig.isJodaTimePresent()) {
|
||||
map.put(org.joda.time.LocalDateTime.class, new GeneratedUpdateJodaTime.LocalDT());
|
||||
map.put(org.joda.time.DateTime.class, new GeneratedUpdateJodaTime.DateTimeDT());
|
||||
@@ -38,7 +36,6 @@ final class UpdateTimestampFactory {
|
||||
}
|
||||
|
||||
void setUpdateTimestamp(DeployBeanProperty property) {
|
||||
|
||||
property.setGeneratedProperty(createUpdateTimestamp(property));
|
||||
}
|
||||
|
||||
@@ -46,13 +43,11 @@ final class UpdateTimestampFactory {
|
||||
* Create the update GeneratedProperty depending on the property type.
|
||||
*/
|
||||
GeneratedProperty createUpdateTimestamp(DeployBeanProperty property) {
|
||||
|
||||
Class<?> propType = property.getPropertyType();
|
||||
GeneratedProperty generatedProperty = map.get(propType);
|
||||
if (generatedProperty != null) {
|
||||
return generatedProperty;
|
||||
}
|
||||
|
||||
throw new PersistenceException("Generated update Timestamp not supported on " + propType.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,15 @@ import java.util.List;
|
||||
/**
|
||||
* For beans with no id properties AKA report type beans.
|
||||
*/
|
||||
public final class IdBinderEmpty implements IdBinder {
|
||||
final class IdBinderEmpty implements IdBinder {
|
||||
|
||||
private static final String bindIdSql = "";
|
||||
|
||||
public IdBinderEmpty() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,22 +119,18 @@ public final class IdBinderEmpty implements IdBinder {
|
||||
|
||||
@Override
|
||||
public void bindId(DefaultSqlUpdate sqlUpdate, Object value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindId(DataBind dataBind, Object value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIdInBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> ids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIdInBindValues(SpiExpressionRequest request, Collection<?> ids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,7 +168,6 @@ public final class IdBinderEmpty implements IdBinder {
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, Object idValue) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,6 @@ public final class IdBinderSimple implements IdBinder {
|
||||
|
||||
@Override
|
||||
public String getOrderBy(String pathPrefix, boolean ascending) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (pathPrefix != null) {
|
||||
sb.append(pathPrefix).append(".");
|
||||
|
||||
@@ -32,9 +32,7 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public void addFkeys(String name) {
|
||||
|
||||
BeanProperty[] embeddedProps = foreignAssocOne.getProperties();
|
||||
|
||||
for (int i = 0; i < imported.length; i++) {
|
||||
String n = name + "." + foreignAssocOne.getName() + "." + embeddedProps[i].getName();
|
||||
BeanFkeyProperty fkey = new BeanFkeyProperty(n, imported[i].localDbColumn, foreignAssocOne.getDeployOrder());
|
||||
@@ -61,7 +59,6 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public void dmlAppend(GenerateDmlRequest request) {
|
||||
|
||||
boolean update = request.isUpdate();
|
||||
for (ImportedIdSimple anImported : imported) {
|
||||
if (anImported.isInclude(update)) {
|
||||
@@ -72,7 +69,6 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public String importedIdClause() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < imported.length; i++) {
|
||||
if (i > 0) {
|
||||
@@ -85,9 +81,7 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public int bind(int position, SqlUpdate update, EntityBean bean) {
|
||||
|
||||
int pos = position;
|
||||
|
||||
EntityBean embedded = (EntityBean) foreignAssocOne.getValue(bean);
|
||||
for (ImportedIdSimple anImported : imported) {
|
||||
if (anImported.owner.isUpdateable()) {
|
||||
@@ -100,9 +94,7 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public Object bind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
|
||||
Object embeddedId = (bean == null) ? null : foreignAssocOne.getValue(bean);
|
||||
|
||||
boolean update = request.isUpdate();
|
||||
if (embeddedId == null) {
|
||||
for (ImportedIdSimple anImported : imported) {
|
||||
@@ -112,7 +104,6 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
}
|
||||
// return anything non-null to skip a derived relationship update
|
||||
return Object.class;
|
||||
|
||||
} else {
|
||||
EntityBean embedded = (EntityBean) embeddedId;
|
||||
for (ImportedIdSimple anImported : imported) {
|
||||
@@ -127,7 +118,6 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
|
||||
@Override
|
||||
public void buildImport(IntersectionRow row, EntityBean other) {
|
||||
|
||||
EntityBean embeddedId = (EntityBean) foreignAssocOne.getValue(other);
|
||||
if (embeddedId == null) {
|
||||
throw new PersistenceException("Foreign Key value null?");
|
||||
@@ -162,7 +152,6 @@ public final class ImportedIdEmbedded implements ImportedId {
|
||||
*/
|
||||
@Override
|
||||
public BeanProperty findMatchImport(String matchDbColumn) {
|
||||
|
||||
for (ImportedIdSimple anImported : imported) {
|
||||
BeanProperty p = anImported.findMatchImport(matchDbColumn);
|
||||
if (p != null) {
|
||||
|
||||
@@ -62,9 +62,7 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
|
||||
* Return the list as an array sorted into the same order as the Bean Properties.
|
||||
*/
|
||||
public static ImportedIdSimple[] sort(List<ImportedIdSimple> list) {
|
||||
|
||||
ImportedIdSimple[] importedIds = list.toArray(new ImportedIdSimple[0]);
|
||||
|
||||
// sort into the same order as the BeanProperties
|
||||
Arrays.sort(importedIds, COMPARATOR);
|
||||
return importedIds;
|
||||
@@ -124,13 +122,11 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
|
||||
|
||||
@Override
|
||||
public void buildImport(IntersectionRow row, EntityBean other) {
|
||||
|
||||
Object value = getIdValue(other);
|
||||
if (value == null) {
|
||||
String msg = "Foreign Key value null?";
|
||||
throw new PersistenceException(msg);
|
||||
}
|
||||
|
||||
row.put(localDbColumn, value);
|
||||
}
|
||||
|
||||
@@ -162,7 +158,6 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
|
||||
|
||||
@Override
|
||||
public Object bind(BindableRequest request, EntityBean bean) throws SQLException {
|
||||
|
||||
Object value = null;
|
||||
if (bean != null) {
|
||||
value = getIdValue(bean);
|
||||
@@ -173,7 +168,6 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
|
||||
|
||||
@Override
|
||||
public BeanProperty findMatchImport(String matchDbColumn) {
|
||||
|
||||
if (matchDbColumn.equals(localDbColumn)) {
|
||||
return foreignProperty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user