Refactor ScalarType, remove convertFromMillis() method (no longer needed)

Due to the move and change of CsvReader using StringParser ScalarType no longer
needs that general convertFromMillis() method. Note that date and dateTime ScalarTypes
still retain this conversion method.
This commit is contained in:
Rob Bygrave committed 2022-08-25 22:37:47 +12:00
1 parent f98b6b0e2a
commit c5e8b217e3
27 files changed
+4 -139

No files matched your search

@@ -190,11 +190,6 @@ public final class BeanFkeyProperty implements ElPropertyValue {
return null;
}
@Override
public Object parseDateTime(long systemTimeMillis) {
throw new RuntimeException("ElPropertyDeploy only - not implemented");
}
@Override
public StringParser stringParser() {
throw new RuntimeException("ElPropertyDeploy only - not implemented");
@@ -945,11 +945,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
return scalarType == null ? 0 : scalarType.jdbcType();
}
@Override
public Object parseDateTime(long systemTimeMillis) {
return scalarType.convertFromMillis(systemTimeMillis);
}
/**
* Return the DB max length (varchar) or precision (decimal).
*/
@@ -232,11 +232,6 @@ public final class ElPropertyChain implements ElPropertyValue {
return scalarType == null ? 0 : scalarType.jdbcType();
}
@Override
public Object parseDateTime(long systemTimeMillis) {
return scalarType.convertFromMillis(systemTimeMillis);
}
@Override
public StringParser stringParser() {
return scalarType;
@@ -77,7 +77,6 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
}
}
@Override
public T convertFromMillis(long systemTimeMillis) {
Date ts = new Date(systemTimeMillis);
return convertFromDate(ts);
@@ -54,7 +54,6 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
/**
* Convert from epoch millis to the value.
*/
@Override
public abstract T convertFromMillis(long systemTimeMillis);
/**
@@ -58,11 +58,6 @@ class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
return new BigDecimal(value);
}
@Override
public BigDecimal convertFromMillis(long systemTimeMillis) {
return BigDecimal.valueOf(systemTimeMillis);
}
@Override
public BigDecimal readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -84,11 +84,6 @@ public final class ScalarTypeBytesEncrypted implements ScalarType<byte[]> {
return baseType.parse(value);
}
@Override
public byte[] convertFromMillis(long systemTimeMillis) {
return baseType.convertFromMillis(systemTimeMillis);
}
@Override
public byte[] read(DataReader reader) throws SQLException {
byte[] data = baseType.read(reader);
@@ -57,11 +57,6 @@ final class ScalarTypeDouble extends ScalarTypeBase<Double> {
return Double.valueOf(value);
}
@Override
public Double convertFromMillis(long systemTimeMillis) {
return (double) systemTimeMillis;
}
@Override
public Double readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -109,11 +109,6 @@ public final class ScalarTypeEncryptedWrapper<T> implements ScalarType<T>, Local
return wrapped.parse(value);
}
@Override
public T convertFromMillis(long systemTimeMillis) {
return wrapped.convertFromMillis(systemTimeMillis);
}
@Override
public T toBeanType(Object value) {
return wrapped.toBeanType(value);
@@ -57,11 +57,6 @@ final class ScalarTypeFloat extends ScalarTypeBase<Float> {
return Float.valueOf(value);
}
@Override
public Float convertFromMillis(long systemTimeMillis) {
return (float) systemTimeMillis;
}
@Override
public Float readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -6,7 +6,6 @@ import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarTypeBase;
import io.ebean.text.TextException;
import io.ebeaninternal.server.core.BasicTypeConverter;
import java.io.DataInput;
@@ -87,11 +86,6 @@ final class ScalarTypeInteger extends ScalarTypeBase<Integer> {
return Integer.valueOf(value);
}
@Override
public Integer convertFromMillis(long systemTimeMillis) {
throw new TextException("Not Supported");
}
@Override
public Integer jsonRead(JsonParser parser) throws IOException {
return parser.getIntValue();
@@ -73,7 +73,6 @@ class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
return new LocalTime(value);
}
@Override
public LocalTime convertFromMillis(long systemTimeMillis) {
return new LocalTime(systemTimeMillis, DateTimeZone.getDefault());
}
@@ -87,11 +87,6 @@ class ScalarTypeLocalTime extends ScalarTypeBase<LocalTime> {
return LocalTime.parse(value);
}
@Override
public LocalTime convertFromMillis(long systemTimeMillis) {
throw new TextException("Not Supported");
}
@Override
public LocalTime jsonRead(JsonParser parser) throws IOException {
return LocalTime.parse(parser.getValueAsString());
@@ -67,11 +67,6 @@ final class ScalarTypeLong extends ScalarTypeBase<Long> {
return value;
}
@Override
public Long convertFromMillis(long systemTimeMillis) {
return systemTimeMillis;
}
@Override
public Long readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -62,11 +62,6 @@ final class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
return new BigInteger(value);
}
@Override
public BigInteger convertFromMillis(long systemTimeMillis) {
return BigInteger.valueOf(systemTimeMillis);
}
@Override
public BigInteger readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -57,11 +57,6 @@ abstract class ScalarTypeStringBase extends ScalarTypeBase<String> {
return value;
}
@Override
public String convertFromMillis(long systemTimeMillis) {
return String.valueOf(systemTimeMillis);
}
@Override
public String readData(DataInput dataInput) throws IOException {
if (!dataInput.readBoolean()) {
@@ -58,7 +58,6 @@ final class ScalarTypeTime extends ScalarTypeBase<Time> {
return Time.valueOf(value);
}
@Override
public Time convertFromMillis(long systemTimeMillis) {
return new Time(systemTimeMillis);
}
@@ -119,15 +119,6 @@ public class ScalarTypeWrapper<B, S> implements ScalarType<B> {
return converter.wrapValue(sv);
}
@Override
public B convertFromMillis(long systemTimeMillis) {
S sv = scalarType.convertFromMillis(systemTimeMillis);
if (sv == null) {
return nullValue;
}
return converter.wrapValue(sv);
}
@Override
public B read(DataReader reader) throws SQLException {
S sv = scalarType.read(reader);