#1747 - Refactor tidy finals, local fields, switches, unused methods

This commit is contained in:
rob bygrave
2019-07-02 21:08:13 +12:00
parent 9b1fa43792
commit 68db6723d0
15 changed files with 30 additions and 84 deletions
@@ -36,8 +36,6 @@ public class BeanCascadeInfo {
refresh = true;
break;
case PERSIST:
save = true;
break;
case MERGE:
save = true;
break;
@@ -92,6 +92,7 @@ import io.ebeanservice.docstore.api.mapping.DocumentMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.persistence.PersistenceException;
import java.io.IOException;
import java.io.StringWriter;
@@ -1289,13 +1290,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return cacheHelp.getNaturalKey();
}
/**
* Return true if there is bean or query caching for this type.
*/
public boolean isCaching() {
return cacheHelp.isCaching();
}
/**
* Return true if there is currently bean caching for this type of bean.
*/
@@ -2117,13 +2111,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
/**
* Get a property value from a bean of this type.
*/
public Object getValue(EntityBean bean, String property) {
return getBeanProperty(property).getValue(bean);
}
/**
* Return true if this bean type should use IdGeneration.
* <p>
@@ -2145,7 +2132,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the class type this BeanDescriptor describes.
*/
@Override
@Override @Nonnull
public Class<T> getBeanType() {
return beanType;
}
@@ -2157,7 +2144,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* instead.
* </p>
*/
@Override
@Override @Nonnull
public String getFullName() {
return fullName;
}
@@ -2165,7 +2152,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the short name of the entity bean.
*/
@Override
@Override @Nonnull
public String getName() {
return name;
}
@@ -2626,13 +2613,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
/**
* Return the name of the server this BeanDescriptor belongs to.
*/
public String getServerName() {
return serverName;
}
/**
* Return true if this bean can cache sharable instances.
* <p>
@@ -3139,7 +3119,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return selectLastInsertedId != null;
}
@Override
@Override @Nonnull
public Collection<? extends Property> allProperties() {
return propertiesAll();
}
@@ -3513,7 +3493,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
jsonHelp.jsonWrite(writeJson, bean, key);
}
void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) throws IOException {
void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) {
jsonHelp.jsonWriteProperties(writeJson, bean);
}
@@ -1259,12 +1259,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
public static boolean isLobType(int type) {
switch (type) {
case Types.CLOB:
return true;
case Types.BLOB:
return true;
case Types.LONGVARBINARY:
return true;
case Types.LONGVARCHAR:
case Types.LONGVARBINARY:
return true;
default:
@@ -1312,13 +1309,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
return excludedFromHistory;
}
/**
* Return true if this is a ManyToMany with history support (on the intersection table).
*/
public boolean isManyToManyWithHistory() {
return false;
}
/**
* Return true if this property hold unmapped JSON.
*/
@@ -426,7 +426,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
@Override
public Object read(DbReadContext ctx) throws SQLException {
public Object read(DbReadContext ctx) {
return null;
}
@@ -957,10 +957,6 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return targetDescriptor.isDocStoreMapped();
}
public BeanCollectionHelp<T> getHelp() {
return help;
}
void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry<?, ?> entry) throws IOException {
elementDescriptor.jsonWriteMapEntry(ctx, entry);
}
@@ -10,7 +10,7 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyOptions;
*/
public class DeployDocPropertyOptions {
private static DocPropertyOptions EMPTY = new DocPropertyOptions();
private static final DocPropertyOptions EMPTY = new DocPropertyOptions();
private DocPropertyOptions mapping;
@@ -54,7 +54,7 @@ public final class DeployUpdateParser extends DeployParser {
}
// append up to the dot
localBuffer.append(currentWord.substring(start, dotPos + 1));
localBuffer.append(currentWord, start, dotPos + 1);
if (dotPos == currentWord.length() - 1) {
// ends with a "." ???
@@ -63,7 +63,7 @@ public final class DeployUpdateParser extends DeployParser {
// get the remainder after the dot
start = dotPos + 1;
String remainder = currentWord.substring(start, currentWord.length());
String remainder = currentWord.substring(start);
String dbWord = getDeployWord(remainder);
if (dbWord != null) {
@@ -5,7 +5,6 @@ import io.ebeaninternal.server.type.DataReader;
import io.ebeaninternal.server.type.ScalarType;
import javax.persistence.PersistenceException;
import java.sql.SQLException;
/**
* Dynamic property based on aggregation (max, min, avg, count).
@@ -39,7 +38,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
}
@Override
public Object read(DataReader dataReader) throws SQLException {
public Object read(DataReader dataReader) {
try {
return scalarType.read(dataReader);
} catch (Exception e) {
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.core.InternString;
* Used to for Assoc Manys to create references etc.
* </p>
*/
public class ExportedProperty {
class ExportedProperty {
private final String foreignDbColumn;
@@ -17,7 +17,7 @@ public class ExportedProperty {
private final boolean embedded;
public ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
this.embedded = embedded;
this.foreignDbColumn = InternString.intern(foreignDbColumn);
this.property = property;
@@ -141,14 +141,13 @@ public final class TableJoin {
return type;
}
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx, String predicate) {
public void addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx, String predicate) {
String[] names = SplitName.split(prefix);
String a1 = ctx.getTableAlias(names[0]);
String a2 = ctx.getTableAlias(prefix);
SqlJoinType returnJoinType = addJoin(joinType, a1, a2, ctx);
addJoin(joinType, a1, a2, ctx);
ctx.append("and ").append(a2).append(predicate);
return returnJoinType;
}
public SqlJoinType addJoin(SqlJoinType joinType, String prefix, DbSqlContext ctx) {
@@ -17,13 +17,12 @@ import java.util.Map;
*/
class InsertTimestampFactory {
private final GeneratedInsertLong longTime = new GeneratedInsertLong();
private final Map<Class<?>, GeneratedProperty> map = new HashMap<>();
InsertTimestampFactory(ClassLoadConfig classLoadConfig) {
map.put(Timestamp.class, new GeneratedInsertTimestamp());
map.put(java.util.Date.class, new GeneratedInsertDate());
GeneratedInsertLong longTime = new GeneratedInsertLong();
map.put(Long.class, longTime);
map.put(long.class, longTime);
@@ -37,7 +36,6 @@ class InsertTimestampFactory {
map.put(org.joda.time.LocalDateTime.class, new GeneratedInsertJodaTime.LocalDT());
map.put(org.joda.time.DateTime.class, new GeneratedInsertJodaTime.DateTimeDT());
}
}
void setInsertTimestamp(DeployBeanProperty property) {
@@ -17,13 +17,12 @@ import java.util.Map;
*/
class UpdateTimestampFactory {
private final GeneratedUpdateLong longTime = new GeneratedUpdateLong();
private final Map<Class<?>, GeneratedProperty> map = new HashMap<>();
UpdateTimestampFactory(ClassLoadConfig classLoadConfig) {
map.put(Timestamp.class, new GeneratedUpdateTimestamp());
map.put(java.util.Date.class, new GeneratedUpdateDate());
GeneratedUpdateLong longTime = new GeneratedUpdateLong();
map.put(Long.class, longTime);
map.put(long.class, longTime);
@@ -127,7 +127,7 @@ public final class IdBinderEmpty implements IdBinder {
}
@Override
public void bindId(DataBind dataBind, Object value) throws SQLException {
public void bindId(DataBind dataBind, Object value) {
}
@@ -146,12 +146,12 @@ public final class IdBinderEmpty implements IdBinder {
}
@Override
public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException {
public Object readSet(DbReadContext ctx, EntityBean bean) {
return null;
}
@Override
public Object read(DbReadContext ctx) throws SQLException {
public Object read(DbReadContext ctx) {
return null;
}
@@ -170,12 +170,12 @@ public final class IdBinderEmpty implements IdBinder {
}
@Override
public Object readData(DataInput dataOutput) throws IOException {
public Object readData(DataInput dataOutput) {
return null;
}
@Override
public void writeData(DataOutput dataOutput, Object idValue) throws IOException {
public void writeData(DataOutput dataOutput, Object idValue) {
}
@@ -41,8 +41,6 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
private final String localSqlFormula;
private final String logicalName;
final BeanProperty foreignProperty;
private final int position;
@@ -66,7 +64,6 @@ public final class ImportedIdSimple implements ImportedId, Comparable<ImportedId
this.position = position;
this.insertable = insertable;
this.updateable = updateable;
this.logicalName = InternString.intern(owner.getName() + "." + foreignProperty.getName());
}
public ImportedIdSimple(BeanPropertyAssoc<?> owner, String localDbColumn, String localSqlFormula, BeanProperty foreignProperty, int position) {
@@ -188,7 +188,7 @@ public class DeployBeanProperty {
*/
private int dbType;
private DeployDocPropertyOptions docMapping = new DeployDocPropertyOptions();
private final DeployDocPropertyOptions docMapping = new DeployDocPropertyOptions();
/**
* The method used to read the property.
@@ -770,22 +770,14 @@ public class DeployBeanProperty {
private boolean isNumericType(int type) {
switch (type) {
case Types.BIGINT:
return true;
case Types.DECIMAL:
return true;
case Types.DOUBLE:
return true;
case Types.FLOAT:
return true;
case Types.INTEGER:
return true;
case Types.NUMERIC:
return true;
case Types.REAL:
return true;
case Types.SMALLINT:
return true;
case Types.TINYINT:
case Types.SMALLINT:
case Types.REAL:
case Types.NUMERIC:
case Types.INTEGER:
case Types.FLOAT:
case Types.DOUBLE:
return true;
default:
@@ -245,8 +245,6 @@ public class DeployUtil {
private int getDbJsonStorage(DbJsonType dbJsonType) {
switch (dbJsonType) {
case JSON:
return DbPlatformType.JSON;
case JSONB:
return DbPlatformType.JSONB;
case VARCHAR: