mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge pull request #2802 from ebean-orm/feature/remove-ScalarType-isDateTimeCapable
Remove ScalarType.isDateTimeCapable() ... (only used by CSV reader)
This commit is contained in:
@@ -45,12 +45,6 @@ public interface ExpressionPath {
|
||||
*/
|
||||
Object parseDateTime(long systemTimeMillis);
|
||||
|
||||
/**
|
||||
* Return true if the last type is "DateTime capable" - can support
|
||||
* {@link #parseDateTime(long)}.
|
||||
*/
|
||||
boolean isDateTimeCapable();
|
||||
|
||||
/**
|
||||
* Return the underlying JDBC type or 0 if this is not a scalar type.
|
||||
*/
|
||||
|
||||
@@ -163,20 +163,6 @@ public interface ScalarType<T> extends StringParser, StringFormatter, ScalarData
|
||||
*/
|
||||
DocPropertyType getDocType();
|
||||
|
||||
/**
|
||||
* Return true if the type can accept long systemTimeMillis input.
|
||||
* <p>
|
||||
* This is used to determine if it is sensible to use the
|
||||
* {@link #convertFromMillis(long)} method.
|
||||
* <p>
|
||||
* This includes the Date, Calendar, sql Date, Time, Timestamp, JODA types
|
||||
* as well as Long, BigDecimal and String (although it generally is not
|
||||
* expected to parse systemTimeMillis to a String or BigDecimal).
|
||||
*/
|
||||
default boolean isDateTimeCapable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the value into a long version value.
|
||||
*/
|
||||
|
||||
@@ -180,11 +180,6 @@ public final class BeanFkeyProperty implements ElPropertyValue {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int jdbcType() {
|
||||
return 0;
|
||||
|
||||
@@ -940,11 +940,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return scalarType != null && scalarType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int jdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
|
||||
@@ -227,12 +227,6 @@ public final class ElPropertyChain implements ElPropertyValue {
|
||||
return lastBeanProperty;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return scalarType != null && scalarType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int jdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
|
||||
@@ -123,11 +123,7 @@ public class TCsvReader<T> implements CsvReader<T> {
|
||||
|
||||
@Override
|
||||
public void addDateTime(String propertyName, String dateTimeFormat, Locale locale) {
|
||||
|
||||
ExpressionPath elProp = descriptor.expressionPath(propertyName);
|
||||
if (!elProp.isDateTimeCapable()) {
|
||||
throw new TextException("Property " + propertyName + " is not DateTime capable");
|
||||
}
|
||||
if (dateTimeFormat == null) {
|
||||
dateTimeFormat = getDefaultDateTimeFormat(elProp.jdbcType());
|
||||
}
|
||||
|
||||
@@ -82,11 +82,6 @@ abstract class ScalarTypeBaseDate<T> extends ScalarTypeBase<T> {
|
||||
return convertFromDate(ts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T jsonRead(JsonParser parser) throws IOException {
|
||||
if (JsonToken.VALUE_NUMBER_INT == parser.getCurrentToken()) {
|
||||
|
||||
@@ -160,11 +160,6 @@ abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -62,11 +62,6 @@ class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
||||
return BigDecimal.valueOf(systemTimeMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -52,11 +52,6 @@ public final class ScalarTypeBytesEncrypted implements ScalarType<byte[]> {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return baseType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJdbcNative() {
|
||||
return baseType.isJdbcNative();
|
||||
|
||||
@@ -61,11 +61,6 @@ final class ScalarTypeDouble extends ScalarTypeBase<Double> {
|
||||
return (double) systemTimeMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -94,11 +94,6 @@ public final class ScalarTypeEncryptedWrapper<T> implements ScalarType<T>, Local
|
||||
return wrapped.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return wrapped.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJdbcNative() {
|
||||
return false;
|
||||
|
||||
@@ -61,11 +61,6 @@ final class ScalarTypeFloat extends ScalarTypeBase<Float> {
|
||||
return (float) systemTimeMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -91,11 +91,6 @@ final class ScalarTypeInteger extends ScalarTypeBase<Integer> {
|
||||
throw new TextException("Not Supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer jsonRead(JsonParser parser) throws IOException {
|
||||
return parser.getIntValue();
|
||||
|
||||
@@ -77,11 +77,6 @@ class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
return new LocalTime(systemTimeMillis, DateTimeZone.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -86,11 +86,6 @@ class ScalarTypeLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
return LocalTime.parse(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime convertFromMillis(long systemTimeMillis) {
|
||||
throw new TextException("Not Supported");
|
||||
|
||||
@@ -71,11 +71,6 @@ final class ScalarTypeLong extends ScalarTypeBase<Long> {
|
||||
return systemTimeMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -66,11 +66,6 @@ final class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
|
||||
return BigInteger.valueOf(systemTimeMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -61,11 +61,6 @@ abstract class ScalarTypeStringBase extends ScalarTypeBase<String> {
|
||||
return String.valueOf(systemTimeMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -62,11 +62,6 @@ final class ScalarTypeTime extends ScalarTypeBase<Time> {
|
||||
return new Time(systemTimeMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Time readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
|
||||
@@ -99,11 +99,6 @@ public class ScalarTypeWrapper<B, S> implements ScalarType<B> {
|
||||
return wrapperType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDateTimeCapable() {
|
||||
return scalarType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJdbcNative() {
|
||||
return false;
|
||||
|
||||
@@ -75,11 +75,6 @@ class ScalarTypeDurationTest {
|
||||
assertEquals(Duration.ofSeconds(1234), duration);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConvertFromMillis() {
|
||||
assertThrows(UnsupportedOperationException.class, () -> type.convertFromMillis(1000));
|
||||
|
||||
-5
@@ -75,11 +75,6 @@ class ScalarTypeDurationWithNanosTest {
|
||||
assertEquals(duration, val1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConvertFromMillis() {
|
||||
assertThrows(UnsupportedOperationException.class, () -> type.convertFromMillis(1000));
|
||||
|
||||
@@ -11,7 +11,8 @@ import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class ScalarTypeInstantTest {
|
||||
|
||||
@@ -107,12 +108,6 @@ public class ScalarTypeInstantTest {
|
||||
assertEquals(now, val1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDateTimeCapable() throws Exception {
|
||||
|
||||
assertTrue(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFromMillis() throws Exception {
|
||||
|
||||
|
||||
@@ -77,11 +77,6 @@ public class ScalarTypeLocalTimeTest {
|
||||
assertEquals(localTime, val1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFromMillis() {
|
||||
assertThrows(TextException.class, () -> type.convertFromMillis(1234));
|
||||
|
||||
-5
@@ -74,11 +74,6 @@ public class ScalarTypeLocalTimeWithNanosTest {
|
||||
assertEquals(localTime, val1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFromMillis() {
|
||||
assertThrows(TextException.class, () -> type.convertFromMillis(1234));
|
||||
|
||||
@@ -6,7 +6,8 @@ import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.time.MonthDay;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class ScalarTypeMonthDayTest {
|
||||
|
||||
@@ -48,11 +49,6 @@ public class ScalarTypeMonthDayTest {
|
||||
assertEquals(value, monthDay);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertFromMillis() {
|
||||
assertThrows(RuntimeException.class, () -> type.convertFromMillis(1203));
|
||||
|
||||
-5
@@ -26,11 +26,6 @@ public class ScalarTypePostgresHstoreTest {
|
||||
assertTrue(hstore.isMutable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDateTimeCapable() {
|
||||
assertFalse(hstore.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDirty() {
|
||||
Map<String, Object> emptyMap = new HashMap<>();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.text.TextException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -71,11 +70,6 @@ class ScalarTypeYearTest {
|
||||
assertEquals(Year.of(2013), year);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsDateTimeCapable() {
|
||||
assertFalse(type.isDateTimeCapable());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConvertFromMillis() {
|
||||
assertThrows(UnsupportedOperationException.class, () -> type.convertFromMillis(1000));
|
||||
|
||||
Reference in New Issue
Block a user