From 4606c7c99f2f836865c13e19d61f5b5f2957601c Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Thu, 19 May 2016 19:58:00 +1200 Subject: [PATCH] No effective change - format and imports --- .../server/type/ArrayElementConverter.java | 10 +- .../server/type/CompoundTypePeriod.java | 2 +- .../server/type/CtCompoundTypeScalarList.java | 102 ++++++------ .../ebeaninternal/server/type/DataReader.java | 1 - .../server/type/DecimalUtils.java | 2 +- .../server/type/DefaultTypeFactory.java | 8 +- .../server/type/DefaultTypeManager.java | 49 +++--- .../server/type/EnumToDbIntegerMap.java | 3 +- .../type/ImmutableCompoundTypeBuilder.java | 149 +++++++++--------- .../server/type/LongToTimestampConverter.java | 4 +- .../server/type/ModifyAwareList.java | 2 +- .../server/type/ScalarTypeArrayList.java | 8 +- .../server/type/ScalarTypeBoolean.java | 4 +- .../server/type/ScalarTypeByte.java | 1 - .../server/type/ScalarTypeCalendar.java | 6 +- .../server/type/ScalarTypeChar.java | 4 +- .../server/type/ScalarTypeCharArray.java | 9 +- .../server/type/ScalarTypeClob.java | 6 +- .../server/type/ScalarTypeDate.java | 4 +- .../server/type/ScalarTypeDayOfWeek.java | 2 +- .../type/ScalarTypeEnumWithMapping.java | 2 - .../server/type/ScalarTypeFile.java | 1 - .../server/type/ScalarTypeFloat.java | 1 - .../server/type/ScalarTypeInetAddress.java | 4 +- .../server/type/ScalarTypeInstant.java | 4 +- .../type/ScalarTypeJodaDateMidnight.java | 7 +- .../type/ScalarTypeJodaLocalDateTime.java | 9 +- .../server/type/ScalarTypeJsonCollection.java | 2 +- .../server/type/ScalarTypeJsonList.java | 12 +- .../server/type/ScalarTypeJsonMap.java | 17 +- .../type/ScalarTypeJsonObjectMapper.java | 6 +- .../server/type/ScalarTypeJsonSet.java | 10 +- .../server/type/ScalarTypeLocalDateTime.java | 6 +- .../server/type/ScalarTypeLong.java | 1 - .../server/type/ScalarTypeMonthDay.java | 1 - .../server/type/ScalarTypeShort.java | 1 - .../server/type/ScalarTypeURI.java | 4 +- .../server/type/ScalarTypeURL.java | 4 +- .../server/type/ScalarTypeUtilDate.java | 6 +- .../server/type/ScalarTypeYear.java | 1 - .../server/type/SimpleAesEncryptor.java | 7 +- .../ebeaninternal/server/type/package.html | 4 +- 42 files changed, 240 insertions(+), 246 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java index 1065650ff..0899fa40a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ArrayElementConverter.java @@ -37,9 +37,9 @@ public interface ArrayElementConverter { @Override public Long toElement(Object rawValue) { if (rawValue instanceof Long) { - return (Long)rawValue; + return (Long) rawValue; } else { - return ((Number)rawValue).longValue(); + return ((Number) rawValue).longValue(); } } } @@ -49,9 +49,9 @@ public interface ArrayElementConverter { @Override public Integer toElement(Object rawValue) { if (rawValue instanceof Integer) { - return (Integer)rawValue; + return (Integer) rawValue; } else { - return ((Number)rawValue).intValue(); + return ((Number) rawValue).intValue(); } } } @@ -72,7 +72,7 @@ public interface ArrayElementConverter { @Override public T toElement(Object rawValue) { - return (T)rawValue; + return (T) rawValue; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CompoundTypePeriod.java b/src/main/java/com/avaje/ebeaninternal/server/type/CompoundTypePeriod.java index 685e2c0b0..0f0402c31 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CompoundTypePeriod.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CompoundTypePeriod.java @@ -23,7 +23,7 @@ public class CompoundTypePeriod implements CompoundType { @Override public Period create(Object[] propertyValues) { - return Period.of((Integer)propertyValues[0], (Integer)propertyValues[1], (Integer)propertyValues[2]); + return Period.of((Integer) propertyValues[0], (Integer) propertyValues[1], (Integer) propertyValues[2]); } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java index 2553c9217..79fe9f2e4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/CtCompoundTypeScalarList.java @@ -1,69 +1,67 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebean.config.CompoundTypeProperty; +import com.avaje.ebeaninternal.server.query.SplitName; + import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; import java.util.Set; -import com.avaje.ebean.config.CompoundTypeProperty; -import com.avaje.ebeaninternal.server.query.SplitName; - /** * Used to build a flat list of all the scalar types nested in a compound type. - * - * @author rbygrave */ public final class CtCompoundTypeScalarList { - private final LinkedHashMap> scalarProps = new LinkedHashMap>(); + private final LinkedHashMap> scalarProps = new LinkedHashMap>(); - private final LinkedHashMap compoundProperties = new LinkedHashMap(); - - /** - * Return the list of non-scalar properties. These occur when compound types are nested. - */ - public List getNonScalarProperties() { - - List nonScalarProps = new ArrayList(); - - for (String propKey: compoundProperties.keySet()) { - if (!scalarProps.containsKey(propKey)){ - nonScalarProps.add(compoundProperties.get(propKey)); - } - } - - return nonScalarProps; + private final LinkedHashMap compoundProperties = new LinkedHashMap(); + + /** + * Return the list of non-scalar properties. These occur when compound types are nested. + */ + public List getNonScalarProperties() { + + List nonScalarProps = new ArrayList(); + + for (String propKey : compoundProperties.keySet()) { + if (!scalarProps.containsKey(propKey)) { + nonScalarProps.add(compoundProperties.get(propKey)); + } } - - /** - * Register a property with it's associated compound type and relative name. - */ - public void addCompoundProperty(String propName, CtCompoundType t, CompoundTypeProperty prop) { - - CtCompoundProperty parent = null; - String[] split = SplitName.split(propName); - if (split[0] != null){ - parent = compoundProperties.get(split[0]); - } - - CtCompoundProperty p = new CtCompoundProperty(propName, parent, t, prop); - compoundProperties.put(propName, p); + + return nonScalarProps; + } + + /** + * Register a property with it's associated compound type and relative name. + */ + public void addCompoundProperty(String propName, CtCompoundType t, CompoundTypeProperty prop) { + + CtCompoundProperty parent = null; + String[] split = SplitName.split(propName); + if (split[0] != null) { + parent = compoundProperties.get(split[0]); } - - /** - * Register a scalarType used in the compound type with its given property name. - */ - public void addScalarType(String propName, ScalarType scalar){ - scalarProps.put(propName, scalar); - } - - public CtCompoundProperty getCompoundType(String propName) { - return compoundProperties.get(propName); - } - - public Set>> entries() { - return scalarProps.entrySet(); - } - + + CtCompoundProperty p = new CtCompoundProperty(propName, parent, t, prop); + compoundProperties.put(propName, p); + } + + /** + * Register a scalarType used in the compound type with its given property name. + */ + public void addScalarType(String propName, ScalarType scalar) { + scalarProps.put(propName, scalar); + } + + public CtCompoundProperty getCompoundType(String propName) { + return compoundProperties.get(propName); + } + + public Set>> entries() { + return scalarProps.entrySet(); + } + } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DataReader.java b/src/main/java/com/avaje/ebeaninternal/server/type/DataReader.java index 3e5d3f8e5..a0112a488 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DataReader.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DataReader.java @@ -1,7 +1,6 @@ package com.avaje.ebeaninternal.server.type; import java.io.InputStream; -import java.io.Reader; import java.math.BigDecimal; import java.sql.Array; import java.sql.SQLException; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DecimalUtils.java b/src/main/java/com/avaje/ebeaninternal/server/type/DecimalUtils.java index e84fd7644..b47696547 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DecimalUtils.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DecimalUtils.java @@ -61,7 +61,7 @@ public final class DecimalUtils { public static BigDecimal toDecimal(Timestamp instant) { long millis = instant.getTime(); - long secs = millis/1000; + long secs = millis / 1000; return new BigDecimal(toDecimal(secs, instant.getNanos())); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactory.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactory.java index 4f4e6fca2..8a67211a2 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeFactory.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.server.type; -import java.math.BigInteger; -import java.sql.Types; -import java.util.Calendar; - import com.avaje.ebean.config.JsonConfig; import com.avaje.ebean.config.ServerConfig; import com.avaje.ebeaninternal.server.core.BasicTypeConverter; +import java.math.BigInteger; +import java.sql.Types; +import java.util.Calendar; + /** * Helper to create some default ScalarType objects for Booleans, * java.util.Date, java.util.Calendar etc. diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java index 4b07685dd..fed245fab 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/DefaultTypeManager.java @@ -377,7 +377,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { // fallback to JSON storage in VARCHAR column return new ScalarTypeJsonList.Varchar(getDocType(getValueType(genericType))); } - throw new IllegalStateException("Type ["+type+"] not supported for @DbArray"); + throw new IllegalStateException("Type [" + type + "] not supported for @DbArray"); } @Override @@ -411,11 +411,16 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { if (type.equals(JsonNode.class)) { switch (dbType) { - case Types.VARCHAR : return jsonNodeVarchar; - case Types.BLOB: return jsonNodeBlob; - case Types.CLOB : return jsonNodeClob; - case DbType.JSONB: return jsonNodeJsonb; - case DbType.JSON: return jsonNodeJson; + case Types.VARCHAR: + return jsonNodeVarchar; + case Types.BLOB: + return jsonNodeBlob; + case Types.CLOB: + return jsonNodeClob; + case DbType.JSONB: + return jsonNodeJsonb; + case DbType.JSON: + return jsonNodeJson; default: return jsonNodeJson; } @@ -520,11 +525,9 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { /** * Convert the Object to the required datatype. The - * - * @param value - * the Object value - * @param toJdbcType - * the type as per java.sql.Types. + * + * @param value the Object value + * @param toJdbcType the type as per java.sql.Types. */ public Object convert(Object value, int toJdbcType) { if (value == null) { @@ -586,7 +589,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return createEnumScalarType(enumType, nameValueMap, integerType, 0); } - + /** * Create a ScalarType for an Enum that has additional mapping. *

@@ -599,7 +602,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { public ScalarType createEnumScalarType(Class> enumType) { Method[] methods = enumType.getMethods(); - for (int i = 0; i createEnumScalarType(Class enumType, Map nameValueMap, boolean integerType, int dbColumnLength) { EnumToDbValueMap beanDbMap = EnumToDbValueMap.create(integerType); int maxValueLen = 0; - for (Map.Entry entry : nameValueMap.entrySet()) { + for (Map.Entry entry : nameValueMap.entrySet()) { String name = entry.getKey(); String value = entry.getValue(); @@ -694,7 +697,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { try { // first try objectMapper constructor Constructor constructor = cls.getConstructor(ObjectMapper.class); - scalarType = (ScalarType)constructor.newInstance((ObjectMapper)objectMapper); + scalarType = (ScalarType) constructor.newInstance((ObjectMapper) objectMapper); } catch (NoSuchMethodException e) { scalarType = (ScalarType) cls.newInstance(); } @@ -720,7 +723,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { return objectMapper; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) protected void initialiseScalarConverters(BootupClasses bootupClasses) { List> foundTypes = bootupClasses.getScalarConverters(); @@ -782,7 +785,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) protected CtCompoundType createCompoundScalarDataReader(Class compoundTypeClass, CompoundType compoundType, String info) { CtCompoundType ctCompoundType = compoundTypeMap.get(compoundTypeClass); @@ -844,7 +847,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { logger.trace("Registering JsonNode type support"); - ObjectMapper mapper = (ObjectMapper)objectMapper; + ObjectMapper mapper = (ObjectMapper) objectMapper; jsonNodeClob = new ScalarTypeJsonNode.Clob(mapper); jsonNodeBlob = new ScalarTypeJsonNode.Blob(mapper); jsonNodeVarchar = new ScalarTypeJsonNode.Varchar(mapper); @@ -887,10 +890,10 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { createCompoundScalarDataReader(Period.class, new CompoundTypePeriod(), ""); boolean localTimeNanos = config.isLocalTimeWithNanos(); - typeMap.put(java.time.LocalTime.class, (localTimeNanos)? new ScalarTypeLocalTimeWithNanos() : new ScalarTypeLocalTime()); + typeMap.put(java.time.LocalTime.class, (localTimeNanos) ? new ScalarTypeLocalTimeWithNanos() : new ScalarTypeLocalTime()); boolean durationNanos = config.isDurationWithNanos(); - typeMap.put(Duration.class, (durationNanos)? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); + typeMap.put(Duration.class, (durationNanos) ? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); } } @@ -921,7 +924,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable { } } } - + /** * Register all the standard types supported. This is the standard JDBC types * plus some other common types such as java.util.Date and java.util.Calendar. diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbIntegerMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbIntegerMap.java index 583207b6a..483cf1a5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbIntegerMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/EnumToDbIntegerMap.java @@ -1,10 +1,9 @@ package com.avaje.ebeaninternal.server.type; +import javax.persistence.PersistenceException; import java.sql.SQLException; import java.sql.Types; -import javax.persistence.PersistenceException; - /** * Used to map enum values to database integer values. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java index c9b170a03..e00afac15 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ImmutableCompoundTypeBuilder.java @@ -10,89 +10,86 @@ import java.util.Map; * been collected then the immutable compound value object is created and * returned. *

- * - * @author rbygrave - * */ public final class ImmutableCompoundTypeBuilder { - private static final ThreadLocal local = new ThreadLocal() { - protected synchronized ImmutableCompoundTypeBuilder initialValue() { - return new ImmutableCompoundTypeBuilder(); - } - }; + private static final ThreadLocal local = new ThreadLocal() { + protected synchronized ImmutableCompoundTypeBuilder initialValue() { + return new ImmutableCompoundTypeBuilder(); + } + }; - private final Map, Entry> entryMap = new HashMap, Entry>(); + private final Map, Entry> entryMap = new HashMap, Entry>(); - /** - * Clear the cache of partial compound objects. - */ - public static void clear() { - local.get().entryMap.clear(); + /** + * Clear the cache of partial compound objects. + */ + public static void clear() { + local.get().entryMap.clear(); + } + + /** + * Set the value for the property of a compound type. + *

+ * If this is the last value required for the compound type then the + * compound type is created and returned, otherwise null is returned (and we + * need more values set). + *

+ */ + public static Object set(CtCompoundType ct, String propName, Object value) { + return local.get().setValue(ct, propName, value); + } + + private Object setValue(CtCompoundType ct, String propName, Object value) { + + Entry e = getEntry(ct); + Object compoundValue = e.set(propName, value); + if (compoundValue != null) { + removeEntry(ct); + } + return compoundValue; + } + + /** + * Once we have built a compound value we remove the entry. + */ + private void removeEntry(CtCompoundType ct) { + entryMap.remove(ct.getCompoundTypeClass()); + } + + /** + * Get the Entry which contains the values collected so far for this type. + */ + private Entry getEntry(CtCompoundType ct) { + Entry e = entryMap.get(ct.getCompoundTypeClass()); + if (e == null) { + e = new Entry(ct); + entryMap.put(ct.getCompoundTypeClass(), e); + } + return e; + } + + /** + * Holds the values collected so far for a given compound type. + */ + private static class Entry { + + private final CtCompoundType ct; + + private final Map valueMap; + + private Entry(CtCompoundType ct) { + this.ct = ct; + this.valueMap = new HashMap(); } - /** - * Set the value for the property of a compound type. - *

- * If this is the last value required for the compound type then the - * compound type is created and returned, otherwise null is returned (and we - * need more values set). - *

- */ - public static Object set(CtCompoundType ct, String propName, Object value) { - return local.get().setValue(ct, propName, value); - } + private Object set(String propName, Object value) { + // collect the values... + valueMap.put(propName, value); - private Object setValue(CtCompoundType ct, String propName, Object value) { - - Entry e = getEntry(ct); - Object compoundValue = e.set(propName, value); - if (compoundValue != null) { - removeEntry(ct); - } - return compoundValue; - } - - /** - * Once we have built a compound value we remove the entry. - */ - private void removeEntry(CtCompoundType ct) { - entryMap.remove(ct.getCompoundTypeClass()); - } - - /** - * Get the Entry which contains the values collected so far for this type. - */ - private Entry getEntry(CtCompoundType ct) { - Entry e = entryMap.get(ct.getCompoundTypeClass()); - if (e == null) { - e = new Entry(ct); - entryMap.put(ct.getCompoundTypeClass(), e); - } - return e; - } - - /** - * Holds the values collected so far for a given compound type. - */ - private static class Entry { - - private final CtCompoundType ct; - - private final Map valueMap; - - private Entry(CtCompoundType ct) { - this.ct = ct; - this.valueMap = new HashMap(); - } - - private Object set(String propName, Object value) { - // collect the values... - valueMap.put(propName, value); - - // when got all the values this returns the - // compound value, otherwise null - return ct.create(valueMap); - } + // when got all the values this returns the + // compound value, otherwise null + return ct.create(valueMap); } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java index b34226875..6f308c516 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/LongToTimestampConverter.java @@ -1,9 +1,9 @@ package com.avaje.ebeaninternal.server.type; -import java.sql.Timestamp; - import com.avaje.ebean.config.ScalarTypeConverter; +import java.sql.Timestamp; + public class LongToTimestampConverter implements ScalarTypeConverter { public Long getNullValue() { diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java index 432941252..2e17c0c66 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ModifyAwareList.java @@ -167,7 +167,7 @@ public class ModifyAwareList implements List, ModifyAwareOwner { @Override public List subList(int fromIndex, int toIndex) { - return new ModifyAwareList(owner,list.subList(fromIndex, toIndex)); + return new ModifyAwareList(owner, list.subList(fromIndex, toIndex)); } /** diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java index 851dbee41..02adbc0b1 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeArrayList.java @@ -45,7 +45,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { if (valueType.equals(String.class)) { return STRING; } - throw new IllegalArgumentException("Type ["+valueType+"] not supported for @DbArray mapping"); + throw new IllegalArgumentException("Type [" + valueType + "] not supported for @DbArray mapping"); } private final String arrayType; @@ -67,7 +67,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { * Return the DB column definition for DDL generation. */ public String getDbColumnDefn() { - return arrayType+"[]"; + return arrayType + "[]"; } @SuppressWarnings("unchecked") @@ -86,7 +86,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { @Override public List read(DataReader reader) throws SQLException { Array array = reader.getArray(); - return fromArray((Object[])array.getArray()); + return fromArray((Object[]) array.getArray()); } @Override @@ -112,7 +112,7 @@ public class ScalarTypeArrayList extends ScalarTypeJsonCollection { try { return EJson.parseList(value, false); } catch (IOException e) { - throw new PersistenceException("Failed to parse JSON content as List: ["+value+"]", e); + throw new PersistenceException("Failed to parse JSON content as List: [" + value + "]", e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBoolean.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBoolean.java index 311a36892..b23d85daf 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBoolean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeBoolean.java @@ -212,12 +212,12 @@ public class ScalarTypeBoolean { @Override public String getDbFalseLiteral() { - return "'"+falseValue+"'"; + return "'" + falseValue + "'"; } @Override public String getDbTrueLiteral() { - return "'"+trueValue+"'"; + return "'" + trueValue + "'"; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeByte.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeByte.java index 80c575c21..3c07a429e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeByte.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeByte.java @@ -5,7 +5,6 @@ import com.avaje.ebeaninternal.server.core.BasicTypeConverter; import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyType; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import java.io.ByteArrayOutputStream; import java.io.DataInput; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCalendar.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCalendar.java index 1df451c41..f392fa614 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCalendar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCalendar.java @@ -1,14 +1,14 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebean.config.JsonConfig; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.sql.Date; import java.sql.SQLException; import java.sql.Timestamp; import java.sql.Types; import java.util.Calendar; -import com.avaje.ebean.config.JsonConfig; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for java.util.Calendar. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeChar.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeChar.java index 567e3bd38..662c4cdf6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeChar.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeChar.java @@ -1,10 +1,10 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.sql.SQLException; import java.sql.Types; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for char. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCharArray.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCharArray.java index f712a9f1c..3206c8ffe 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCharArray.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeCharArray.java @@ -1,13 +1,12 @@ package com.avaje.ebeaninternal.server.type; -import java.io.IOException; -import java.sql.SQLException; -import java.sql.Types; - import com.avaje.ebeaninternal.server.core.BasicTypeConverter; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.Types; /** * ScalarType for char[]. diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeClob.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeClob.java index ee8ea19e7..e4c1d09e8 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeClob.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeClob.java @@ -1,15 +1,15 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.sql.SQLException; import java.sql.Types; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for String. */ public class ScalarTypeClob extends ScalarTypeBaseVarchar { - + protected ScalarTypeClob(boolean jdbcNative, int jdbcType) { super(String.class, jdbcNative, jdbcType); } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDate.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDate.java index 986c273aa..d9acea851 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDate.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; + import java.sql.Date; import java.sql.SQLException; import java.sql.Types; -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for java.sql.Date. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDayOfWeek.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDayOfWeek.java index 30f5e5a48..5c2a9a8a9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDayOfWeek.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeDayOfWeek.java @@ -31,7 +31,7 @@ public class ScalarTypeDayOfWeek extends ScalarTypeEnumWithMapping { b.setNull(Types.INTEGER); } else { // avoiding the map lookup - b.setInt(((DayOfWeek)value).getValue()); + b.setInt(((DayOfWeek) value).getValue()); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java index 9db8ca3fd..5a8a5eb94 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeEnumWithMapping.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.type; -import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyType; - import java.sql.SQLException; import java.util.Iterator; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFile.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFile.java index 64c69efb8..3f227602d 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFile.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFile.java @@ -4,7 +4,6 @@ import com.avaje.ebean.text.TextException; import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyType; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFloat.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFloat.java index 4d483a5ae..3408df068 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFloat.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeFloat.java @@ -4,7 +4,6 @@ import com.avaje.ebeaninternal.server.core.BasicTypeConverter; import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyType; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; import java.io.DataInput; import java.io.DataOutput; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInetAddress.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInetAddress.java index a1ce30a37..e0ca0e0f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInetAddress.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInetAddress.java @@ -1,9 +1,9 @@ package com.avaje.ebeaninternal.server.type; -import java.net.InetAddress; - import com.avaje.ebean.text.TextException; +import java.net.InetAddress; + /** * ScalarType for java.net.URI which converts to and from a VARCHAR database column. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstant.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstant.java index 95f25e478..8715efb17 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstant.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeInstant.java @@ -47,13 +47,13 @@ public class ScalarTypeInstant extends ScalarTypeBaseDateTime { @Override public Object toJdbcType(Object value) { - if (value instanceof Timestamp) return value; + if (value instanceof Timestamp) return value; return convertToTimestamp((Instant) value); } @Override public Instant toBeanType(Object value) { - if (value instanceof Instant) return (Instant) value; + if (value instanceof Instant) return (Instant) value; return convertFromTimestamp((Timestamp) value); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaDateMidnight.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaDateMidnight.java index 5a0c66c77..358ece675 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaDateMidnight.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaDateMidnight.java @@ -1,12 +1,11 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; +import org.joda.time.DateMidnight; + import java.sql.Date; import java.sql.Types; -import org.joda.time.DateMidnight; - -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for Joda DateMidnight. This maps to a JDBC Date. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTime.java index cda901d66..1d3c516a0 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJodaLocalDateTime.java @@ -1,13 +1,12 @@ package com.avaje.ebeaninternal.server.type; +import com.avaje.ebean.config.JsonConfig; +import com.avaje.ebeaninternal.server.core.BasicTypeConverter; +import org.joda.time.LocalDateTime; + import java.sql.Timestamp; import java.sql.Types; -import com.avaje.ebean.config.JsonConfig; -import org.joda.time.LocalDateTime; - -import com.avaje.ebeaninternal.server.core.BasicTypeConverter; - /** * ScalarType for Joda LocalDateTime. This maps to a JDBC Timestamp. */ diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonCollection.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonCollection.java index 27cf80165..8f0d8df5b 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonCollection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonCollection.java @@ -39,7 +39,7 @@ abstract class ScalarTypeJsonCollection extends ScalarTypeBase { @Override @SuppressWarnings("unchecked") public T toBeanType(Object value) { - return (T)value; + return (T) value; } @Override diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonList.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonList.java index 64155a6c6..5e5e5589e 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonList.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonList.java @@ -15,15 +15,17 @@ import java.util.List; /** * Types for mapping List in JSON format to DB types VARCHAR, JSON and JSONB. */ -public class ScalarTypeJsonList { +public class ScalarTypeJsonList { /** * Return the appropriate ScalarType based requested dbType and if Postgres. */ public static ScalarType typeFor(boolean postgres, int dbType, DocPropertyType docType) { if (postgres) { switch (dbType) { - case DbType.JSONB: return new ScalarTypeJsonList.JsonB(docType); - case DbType.JSON: return new ScalarTypeJsonList.Json(docType); + case DbType.JSONB: + return new ScalarTypeJsonList.JsonB(docType); + case DbType.JSON: + return new ScalarTypeJsonList.Json(docType); } } return new ScalarTypeJsonList.Varchar(docType); @@ -71,7 +73,7 @@ public class ScalarTypeJsonList { // parse JSON into modifyAware list return EJson.parseList(dataReader.getString(), true); } catch (IOException e) { - throw new SQLException("Failed to parse JSON content as List: ["+ dataReader.getString() +"]", e); + throw new SQLException("Failed to parse JSON content as List: [" + dataReader.getString() + "]", e); } } @@ -105,7 +107,7 @@ public class ScalarTypeJsonList { try { return EJson.parseList(value, false); } catch (IOException e) { - throw new PersistenceException("Failed to parse JSON content as List: ["+value+"]", e); + throw new PersistenceException("Failed to parse JSON content as List: [" + value + "]", e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonMap.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonMap.java index 670e40e50..c946b6f29 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonMap.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonMap.java @@ -35,13 +35,18 @@ public abstract class ScalarTypeJsonMap extends ScalarTypeBase { public static ScalarTypeJsonMap typeFor(boolean postgres, int dbType) { switch (dbType) { - case Types.VARCHAR : return VARCHAR; - case Types.BLOB: return BLOB; - case Types.CLOB : return CLOB; - case DbType.JSONB: return postgres ? JSONB : CLOB; - case DbType.JSON: return postgres ? JSON : CLOB; + case Types.VARCHAR: + return VARCHAR; + case Types.BLOB: + return BLOB; + case Types.CLOB: + return CLOB; + case DbType.JSONB: + return postgres ? JSONB : CLOB; + case DbType.JSON: + return postgres ? JSON : CLOB; default: - throw new IllegalStateException("Unknown dbType "+dbType); + throw new IllegalStateException("Unknown dbType " + dbType); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java index 587be6fa7..ad9e512d3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java @@ -45,8 +45,10 @@ public class ScalarTypeJsonObjectMapper { private static String getPostgresType(boolean postgres, int dbType) { if (postgres) { switch (dbType) { - case DbType.JSON : return PostgresHelper.JSON_TYPE; - case DbType.JSONB : return PostgresHelper.JSONB_TYPE; + case DbType.JSON: + return PostgresHelper.JSON_TYPE; + case DbType.JSONB: + return PostgresHelper.JSONB_TYPE; } } return null; diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonSet.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonSet.java index b35b352bd..798acdac6 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonSet.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeJsonSet.java @@ -25,8 +25,10 @@ public class ScalarTypeJsonSet { public static ScalarType typeFor(boolean postgres, int dbType, DocPropertyType docPropertyType) { if (postgres) { switch (dbType) { - case DbType.JSONB: return new ScalarTypeJsonSet.JsonB(docPropertyType); - case DbType.JSON: return new ScalarTypeJsonSet.Json(docPropertyType); + case DbType.JSONB: + return new ScalarTypeJsonSet.JsonB(docPropertyType); + case DbType.JSON: + return new ScalarTypeJsonSet.Json(docPropertyType); } } return new ScalarTypeJsonSet.Varchar(docPropertyType); @@ -74,7 +76,7 @@ public class ScalarTypeJsonSet { // parse JSON into modifyAware list return EJson.parseSet(dataReader.getString(), true); } catch (IOException e) { - throw new SQLException("Failed to parse JSON content as List: ["+ dataReader.getString() +"]", e); + throw new SQLException("Failed to parse JSON content as List: [" + dataReader.getString() + "]", e); } } @@ -108,7 +110,7 @@ public class ScalarTypeJsonSet { try { return convertList(EJson.parseList(value)); } catch (IOException e) { - throw new PersistenceException("Failed to parse JSON content as Set: ["+value+"]", e); + throw new PersistenceException("Failed to parse JSON content as Set: [" + value + "]", e); } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTime.java b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTime.java index 65bf28303..e9142ca92 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTime.java +++ b/src/main/java/com/avaje/ebeaninternal/server/type/ScalarTypeLocalDateTime.java @@ -49,12 +49,12 @@ public class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime - - Scalar Type support + + Scalar Type support Built in and custom Scalar types support.