diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java index e358dd891..242b657f3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/AttributeConverterAdapter.java @@ -7,7 +7,7 @@ import javax.persistence.AttributeConverter; /** * Adapter from ScalarTypeConverter to AttributeConverter. */ -class AttributeConverterAdapter implements ScalarTypeConverter { +final class AttributeConverterAdapter implements ScalarTypeConverter { private final AttributeConverter converter; private final B nullValue; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBind.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBind.java index a1a9ec8cf..89603122b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBind.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBind.java @@ -26,15 +26,10 @@ public class DataBind implements DataBinder { private static final Logger log = LoggerFactory.getLogger(DataBind.class); private final DataTimeZone dataTimeZone; - private final PreparedStatement pstmt; - private final Connection connection; - private final StringBuilder bindLog = new StringBuilder(); - private List inputStreams; - protected int pos; private String json; @@ -45,35 +40,35 @@ public class DataBind implements DataBinder { } @Override - public void pushJson(String json) { + public final void pushJson(String json) { assert this.json == null; // we can only push one value this.json = json; } @Override - public String popJson() { + public final String popJson() { String ret = json; json = null; return ret; } @Override - public StringBuilder append(Object entry) { + public final StringBuilder append(Object entry) { return bindLog.append(entry); } @Override - public StringBuilder log() { + public final StringBuilder log() { return bindLog; } @Override - public void close() throws SQLException { + public final void close() throws SQLException { pstmt.close(); } @Override - public int currentPos() { + public final int currentPos() { return pos; } @@ -83,7 +78,7 @@ public class DataBind implements DataBinder { } @Override - public void setObject(Object value, int sqlType) throws SQLException { + public final void setObject(Object value, int sqlType) throws SQLException { pstmt.setObject(++pos, value, sqlType); } @@ -93,17 +88,17 @@ public class DataBind implements DataBinder { } @Override - public int nextPos() { + public final int nextPos() { return ++pos; } @Override - public void decrementPos() { + public final void decrementPos() { --pos; } @Override - public int executeUpdate() throws SQLException { + public final int executeUpdate() throws SQLException { try { return pstmt.executeUpdate(); } finally { @@ -125,7 +120,7 @@ public class DataBind implements DataBinder { } @Override - public PreparedStatement getPstmt() { + public final PreparedStatement getPstmt() { return pstmt; } @@ -135,37 +130,37 @@ public class DataBind implements DataBinder { } @Override - public void setInt(int i) throws SQLException { + public final void setInt(int i) throws SQLException { pstmt.setInt(++pos, i); } @Override - public void setLong(long i) throws SQLException { + public final void setLong(long i) throws SQLException { pstmt.setLong(++pos, i); } @Override - public void setShort(short i) throws SQLException { + public final void setShort(short i) throws SQLException { pstmt.setShort(++pos, i); } @Override - public void setFloat(float i) throws SQLException { + public final void setFloat(float i) throws SQLException { pstmt.setFloat(++pos, i); } @Override - public void setDouble(double i) throws SQLException { + public final void setDouble(double i) throws SQLException { pstmt.setDouble(++pos, i); } @Override - public void setBigDecimal(BigDecimal v) throws SQLException { + public final void setBigDecimal(BigDecimal v) throws SQLException { pstmt.setBigDecimal(++pos, v); } @Override - public void setDate(java.sql.Date v) throws SQLException { + public final void setDate(java.sql.Date v) throws SQLException { Calendar timeZone = dataTimeZone.getDateTimeZone(); if (timeZone != null) { pstmt.setDate(++pos, v, timeZone); @@ -175,7 +170,7 @@ public class DataBind implements DataBinder { } @Override - public void setTimestamp(Timestamp v) throws SQLException { + public final void setTimestamp(Timestamp v) throws SQLException { Calendar timeZone = dataTimeZone.getTimeZone(); if (timeZone != null) { pstmt.setTimestamp(++pos, v, timeZone); @@ -185,7 +180,7 @@ public class DataBind implements DataBinder { } @Override - public void setTime(Time v) throws SQLException { + public final void setTime(Time v) throws SQLException { Calendar timeZone = dataTimeZone.getTimeZone(); if (timeZone != null) { pstmt.setTime(++pos, v, timeZone); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBindCapture.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBindCapture.java index e87ebf471..659d0ef06 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBindCapture.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataBindCapture.java @@ -7,7 +7,7 @@ import io.ebeaninternal.server.type.bindcapture.BindCaptureStatement; /** * Special DataBind used to capture bind values for obtaining explain plans. */ -public class DataBindCapture extends DataBind { +public final class DataBindCapture extends DataBind { private final BindCaptureStatement captureStatement; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataEncryptSupport.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataEncryptSupport.java index 32d87cd91..791d3e78e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DataEncryptSupport.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DataEncryptSupport.java @@ -4,7 +4,7 @@ import io.ebean.config.EncryptKey; import io.ebean.config.EncryptKeyManager; import io.ebean.config.Encryptor; -public class DataEncryptSupport { +public final class DataEncryptSupport { private final EncryptKeyManager encryptKeyManager; private final Encryptor encryptor; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java index 60e3f6d6e..72f2d4e96 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DecimalUtils.java @@ -38,10 +38,8 @@ public final class DecimalUtils { } public static Duration toDuration(BigDecimal value) { - long seconds = value.longValue(); int nanoseconds = extractNanosecondDecimal(value, seconds); - return Duration.ofSeconds(seconds, nanoseconds); } @@ -50,10 +48,8 @@ public final class DecimalUtils { } public static Timestamp toTimestamp(BigDecimal value) { - long seconds = value.longValue(); int nanoseconds = extractNanosecondDecimal(value, seconds); - Timestamp ts = new Timestamp(seconds * 1000); ts.setNanos(nanoseconds); return ts; @@ -66,7 +62,6 @@ public final class DecimalUtils { } public static Instant toInstant(BigDecimal value) { - long seconds = value.longValue(); int nanoseconds = extractNanosecondDecimal(value, seconds); return Instant.ofEpochSecond(seconds, nanoseconds); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java index 22f50b937..6c2f3b860 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java @@ -14,7 +14,7 @@ import java.util.Date; * Helper to create some default ScalarType objects for Booleans, * java.util.Date, java.util.Calendar etc. */ -public class DefaultTypeFactory { +public final class DefaultTypeFactory { private final DatabaseConfig config; @@ -22,7 +22,7 @@ public class DefaultTypeFactory { this.config = config; } - protected ScalarTypeBool createBoolean(String trueValue, String falseValue) { + ScalarTypeBool createBoolean(String trueValue, String falseValue) { try { // first try Integer based boolean Integer intTrue = BasicTypeConverter.toInteger(trueValue); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbIntegerMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbIntegerMap.java index 7d62a8391..419d8f53a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbIntegerMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbIntegerMap.java @@ -10,7 +10,7 @@ import java.sql.Types; /** * Used to map enum values to database integer values. */ -public class EnumToDbIntegerMap extends EnumToDbValueMap { +public final class EnumToDbIntegerMap extends EnumToDbValueMap { @Override public int getDbType() { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbStringMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbStringMap.java index 05b0f8991..c7dc4bc89 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbStringMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbStringMap.java @@ -9,7 +9,7 @@ import java.sql.Types; /** * Used to map Enum values to database string/varchar values. */ -public class EnumToDbStringMap extends EnumToDbValueMap { +public final class EnumToDbStringMap extends EnumToDbValueMap { @Override public int getDbType() { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbValueMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbValueMap.java index 08240cabc..57ab47ef5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbValueMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/EnumToDbValueMap.java @@ -22,13 +22,9 @@ public abstract class EnumToDbValueMap { } final LinkedHashMap keyMap; - final LinkedHashMap valueMap; - final HashMap nameMap; - final boolean allowNulls; - final boolean isIntegerType; /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java index 90a86ec79..7daee8bd5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java @@ -9,7 +9,7 @@ import java.util.Set; /** * Initialise the Jackson ObjectMapper. */ -class InitObjectMapper { +final class InitObjectMapper { /** * Create and return the default ObjectMapper. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/IsoJsonDateTimeParser.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/IsoJsonDateTimeParser.java index a6f8a8636..fd4373062 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/IsoJsonDateTimeParser.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/IsoJsonDateTimeParser.java @@ -4,7 +4,7 @@ import java.time.Instant; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; -class IsoJsonDateTimeParser { +final class IsoJsonDateTimeParser { private static final DateTimeFormatter ISO_MILLIS = new DateTimeFormatterBuilder() .parseCaseInsensitive() diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java index 1e1db244d..7d2d5b3e1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java @@ -3,7 +3,7 @@ package io.ebeaninternal.server.type; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.AnnotatedField; -class JacksonTypeHelper { +final class JacksonTypeHelper { private final AnnotatedField field; private final ObjectMapper objectMapper; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/LongToTimestampConverter.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/LongToTimestampConverter.java index e396602d4..83d55871d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/LongToTimestampConverter.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/LongToTimestampConverter.java @@ -4,7 +4,7 @@ import io.ebean.config.ScalarTypeConverter; import java.sql.Timestamp; -public class LongToTimestampConverter implements ScalarTypeConverter { +public final class LongToTimestampConverter implements ScalarTypeConverter { @Override public Long getNullValue() { @@ -13,15 +13,12 @@ public class LongToTimestampConverter implements ScalarTypeConverter entries = new ArrayList<>(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureStatement.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureStatement.java index e8cda7b13..916c1c355 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureStatement.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureStatement.java @@ -12,7 +12,7 @@ import java.util.Calendar; /** * Special PreparedStatement used to capture bind values used to obtain explain plans. */ -public class BindCaptureStatement extends BindCaptureStatementBase implements PreparedStatement { +public final class BindCaptureStatement extends BindCaptureStatementBase implements PreparedStatement { private final BindCapture capture = new BindCapture(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureTypes.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureTypes.java index 1c859c8fb..b2e36f828 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureTypes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/bindcapture/BindCaptureTypes.java @@ -13,9 +13,9 @@ import java.sql.Timestamp; import java.util.Arrays; import java.util.Calendar; -class BindCaptureTypes { +final class BindCaptureTypes { - static class Null implements BindCaptureEntry { + static final class Null implements BindCaptureEntry { private final int parameterIndex; private final int sqlType; @@ -36,7 +36,7 @@ class BindCaptureTypes { } } - static class Boolean implements BindCaptureEntry { + static final class Boolean implements BindCaptureEntry { private final int parameterIndex; private final boolean x; @@ -57,7 +57,7 @@ class BindCaptureTypes { } } - static class Byte implements BindCaptureEntry { + static final class Byte implements BindCaptureEntry { private final int parameterIndex; private final byte x; @@ -78,7 +78,7 @@ class BindCaptureTypes { } } - static class Bytes implements BindCaptureEntry { + static final class Bytes implements BindCaptureEntry { private final int parameterIndex; private final byte[] x; @@ -99,7 +99,7 @@ class BindCaptureTypes { } } - static class TShort implements BindCaptureEntry { + static final class TShort implements BindCaptureEntry { private final int parameterIndex; private final short value; @@ -120,7 +120,7 @@ class BindCaptureTypes { } } - static class TInt implements BindCaptureEntry { + static final class TInt implements BindCaptureEntry { private final int parameterIndex; private final int value; @@ -141,7 +141,7 @@ class BindCaptureTypes { } } - static class TLong implements BindCaptureEntry { + static final class TLong implements BindCaptureEntry { private final int parameterIndex; private final long value; @@ -162,7 +162,7 @@ class BindCaptureTypes { } } - static class TFloat implements BindCaptureEntry { + static final class TFloat implements BindCaptureEntry { private final int parameterIndex; private final float value; @@ -183,7 +183,7 @@ class BindCaptureTypes { } } - static class TDouble implements BindCaptureEntry { + static final class TDouble implements BindCaptureEntry { private final int parameterIndex; private final double value; @@ -204,7 +204,7 @@ class BindCaptureTypes { } } - static class TBigDecimal implements BindCaptureEntry { + static final class TBigDecimal implements BindCaptureEntry { private final int parameterIndex; private final BigDecimal value; @@ -226,7 +226,7 @@ class BindCaptureTypes { } - static class TString implements BindCaptureEntry { + static final class TString implements BindCaptureEntry { private final int parameterIndex; private final String value; @@ -247,7 +247,7 @@ class BindCaptureTypes { } } - static class TDate implements BindCaptureEntry { + static final class TDate implements BindCaptureEntry { private final int parameterIndex; private final Date value; @@ -268,7 +268,7 @@ class BindCaptureTypes { } } - static class TTime implements BindCaptureEntry { + static final class TTime implements BindCaptureEntry { private final int parameterIndex; private final Time value; @@ -289,7 +289,7 @@ class BindCaptureTypes { } } - static class TTimestamp implements BindCaptureEntry { + static final class TTimestamp implements BindCaptureEntry { private final int parameterIndex; private final Timestamp value; @@ -316,7 +316,7 @@ class BindCaptureTypes { } } - static class TObject implements BindCaptureEntry { + static final class TObject implements BindCaptureEntry { private final int parameterIndex; private final Object value; @@ -337,13 +337,12 @@ class BindCaptureTypes { } } - static class TArray implements BindCaptureEntry { + static final class TArray implements BindCaptureEntry { private final int parameterIndex; private final String arrayType; private final Object[] elements; - TArray(int parameterIndex, String arrayType, Object[] elements) { this.parameterIndex = parameterIndex; this.arrayType = arrayType; @@ -362,7 +361,7 @@ class BindCaptureTypes { } } - static class CharacterStream implements BindCaptureEntry { + static final class CharacterStream implements BindCaptureEntry { private static final String dummy = "hi"; @@ -383,7 +382,7 @@ class BindCaptureTypes { } } - static class BinaryStream implements BindCaptureEntry { + static final class BinaryStream implements BindCaptureEntry { private static final byte[] dummy = "hi".getBytes(Charset.defaultCharset());