mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#585 - Refactor of ScalarType jsonWrite() method such that it only takes JsonGenerator - part 4, tidy up
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.avaje.ebeaninternal.server.type;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Utility methods for ScalarTypes.
|
||||
*/
|
||||
public class ScalarHelp {
|
||||
|
||||
/**
|
||||
* Write the string content as UTF with the proceeding boolean true indicating the non-null.
|
||||
*/
|
||||
public static void writeUTF(DataOutput dataOutput, String content) throws IOException {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(content);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.avaje.ebean.config.JsonConfig;
|
||||
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;
|
||||
@@ -126,14 +125,12 @@ public abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
|
||||
return DocPropertyType.DATETIME;
|
||||
}
|
||||
|
||||
public String formatValue(T t) {
|
||||
Timestamp ts = convertToTimestamp(t);
|
||||
return ts.toString();
|
||||
public String formatValue(T value) {
|
||||
return convertToTimestamp(value).toString();
|
||||
}
|
||||
|
||||
public T parse(String value) {
|
||||
Timestamp ts = Timestamp.valueOf(value);
|
||||
return convertFromTimestamp(ts);
|
||||
return convertFromTimestamp(Timestamp.valueOf(value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -50,7 +49,6 @@ public abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
|
||||
public void bind(DataBind b, T value) throws SQLException {
|
||||
if (value == null) {
|
||||
b.setNull(Types.VARCHAR);
|
||||
|
||||
} else {
|
||||
b.setString(convertToDbString(value));
|
||||
}
|
||||
@@ -107,19 +105,15 @@ public abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T> {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
String val = dataInput.readUTF();
|
||||
return convertFromDbString(val);
|
||||
return convertFromDbString(dataInput.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
public void writeData(DataOutput dataOutput, T value) throws IOException {
|
||||
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
String s = convertToDbString(value);
|
||||
dataOutput.writeUTF(s);
|
||||
ScalarHelp.writeUTF(dataOutput, convertToDbString(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -22,25 +21,6 @@ public class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
||||
super(BigDecimal.class, true, Types.DECIMAL);
|
||||
}
|
||||
|
||||
public BigDecimal readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
double val = dataInput.readDouble();
|
||||
return new BigDecimal(val);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeData(DataOutput dataOutput, BigDecimal b) throws IOException {
|
||||
|
||||
if (b == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeDouble(b.doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(DataBind b, BigDecimal value) throws SQLException {
|
||||
if (value == null) {
|
||||
b.setNull(Types.DECIMAL);
|
||||
@@ -78,6 +58,24 @@ public class ScalarTypeBigDecimal extends ScalarTypeBase<BigDecimal> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BigDecimal readData(DataInput dataInput) throws IOException {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
return new BigDecimal(dataInput.readDouble());
|
||||
}
|
||||
}
|
||||
|
||||
public void writeData(DataOutput dataOutput, BigDecimal b) throws IOException {
|
||||
|
||||
if (b == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeDouble(b.doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal jsonRead(JsonParser parser) throws IOException {
|
||||
return parser.getDecimalValue();
|
||||
|
||||
@@ -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 java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInput;
|
||||
@@ -41,23 +40,6 @@ public abstract class ScalarTypeBytesBase extends ScalarTypeBase<byte[]> {
|
||||
return (byte[]) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jsonWrite(JsonGenerator writer, byte[] value) throws IOException {
|
||||
writer.writeBinary(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] jsonRead(JsonParser parser) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(500);
|
||||
parser.readBinaryValue(out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.BINARY;
|
||||
}
|
||||
|
||||
public String formatValue(byte[] t) {
|
||||
throw new TextException("Not supported");
|
||||
}
|
||||
@@ -96,4 +78,20 @@ public abstract class ScalarTypeBytesBase extends ScalarTypeBase<byte[]> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jsonWrite(JsonGenerator writer, byte[] value) throws IOException {
|
||||
writer.writeBinary(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] jsonRead(JsonParser parser) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(500);
|
||||
parser.readBinaryValue(out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.BINARY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -77,8 +76,7 @@ public class ScalarTypeDuration extends ScalarTypeBase<Duration> {
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(convertToBigDecimal(value).toString());
|
||||
ScalarHelp.writeUTF(dataOutput, convertToBigDecimal(value).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.type;
|
||||
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;
|
||||
|
||||
@@ -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 java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
@@ -208,13 +207,13 @@ public class ScalarTypeEnumStandard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(Object t) {
|
||||
return ((Enum<?>) t).name();
|
||||
public String format(Object value) {
|
||||
return ((Enum<?>) value).name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatValue(Object t) {
|
||||
return ((Enum<?>) t).name();
|
||||
public String formatValue(Object value) {
|
||||
return ((Enum<?>) value).name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,20 +251,17 @@ public class ScalarTypeEnumStandard {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
String s = dataInput.readUTF();
|
||||
return parse(s);
|
||||
return parse(dataInput.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, Object v) throws IOException {
|
||||
if (v == null) {
|
||||
public void writeData(DataOutput dataOutput, Object value) throws IOException {
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(format(v));
|
||||
ScalarHelp.writeUTF(dataOutput, format(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -71,24 +71,6 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
return new LocalTime(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jsonWrite(JsonGenerator writer, LocalTime value) throws IOException {
|
||||
writer.writeString(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime jsonRead(JsonParser parser) throws IOException {
|
||||
if (JsonToken.VALUE_NUMBER_INT == parser.getCurrentToken()) {
|
||||
return convertFromMillis(parser.getLongValue());
|
||||
} else {
|
||||
return parse(parser.getValueAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime convertFromMillis(long systemTimeMillis) {
|
||||
@@ -120,4 +102,23 @@ public class ScalarTypeJodaLocalTime extends ScalarTypeBase<LocalTime> {
|
||||
dataOutput.writeUTF(format(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jsonWrite(JsonGenerator writer, LocalTime value) throws IOException {
|
||||
writer.writeString(value.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalTime jsonRead(JsonParser parser) throws IOException {
|
||||
if (JsonToken.VALUE_NUMBER_INT == parser.getCurrentToken()) {
|
||||
return convertFromMillis(parser.getLongValue());
|
||||
} else {
|
||||
return parse(parser.getValueAsString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.STRING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.avaje.ebean.text.json.EJson;
|
||||
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;
|
||||
@@ -177,19 +176,16 @@ public abstract class ScalarTypeJsonMap extends ScalarTypeBase<Map> {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
String json = dataInput.readUTF();
|
||||
return parse(json);
|
||||
return parse(dataInput.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, Map v) throws IOException {
|
||||
if (v == null) {
|
||||
public void writeData(DataOutput dataOutput, Map map) throws IOException {
|
||||
if (map == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
String json = format(v);
|
||||
dataOutput.writeUTF(json);
|
||||
ScalarHelp.writeUTF(dataOutput, format(map));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,17 +194,14 @@ public abstract class ScalarTypeJsonMap extends ScalarTypeBase<Map> {
|
||||
EJson.write(value, writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map jsonRead(JsonParser parser) throws IOException {
|
||||
return EJson.parseObject(parser, parser.getCurrentToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map jsonRead(JsonParser parser) throws IOException {
|
||||
// at this point the BeanProperty has read the START_OBJECT token
|
||||
// to check for a null value. Pass the START_OBJECT token through to
|
||||
// the EJson parsing so that it knows the first token has been read
|
||||
return EJson.parseObject(parser, parser.getCurrentToken());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -189,8 +188,7 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
String json = dataInput.readUTF();
|
||||
return parse(json);
|
||||
return parse(dataInput.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,9 +197,7 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
String json = format(value);
|
||||
dataOutput.writeUTF(json);
|
||||
ScalarHelp.writeUTF(dataOutput, format(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,16 +206,14 @@ public abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
|
||||
objectMapper.writeTree(writer, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonNode jsonRead(JsonParser parser) throws IOException {
|
||||
return objectMapper.readValue(parser, JsonNode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocPropertyType getDocType() {
|
||||
return DocPropertyType.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonNode jsonRead(JsonParser parser) throws IOException {
|
||||
// at this point the BeanProperty has read the START_OBJECT token
|
||||
// to check for a null value.
|
||||
return objectMapper.readValue(parser, JsonNode.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -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;
|
||||
@@ -34,11 +33,11 @@ public class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
|
||||
@Override
|
||||
public BigInteger read(DataReader dataReader) throws SQLException {
|
||||
|
||||
Long l = dataReader.getLong();
|
||||
if (l == null) {
|
||||
Long value = dataReader.getLong();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return new BigInteger(String.valueOf(l));
|
||||
return new BigInteger(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,8 +75,7 @@ public class ScalarTypeMathBigInteger extends ScalarTypeBase<BigInteger> {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
long val = dataInput.readLong();
|
||||
return BigInteger.valueOf(val);
|
||||
return BigInteger.valueOf(dataInput.readLong());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ public class ScalarTypeMonthDay extends ScalarTypeBase<MonthDay> {
|
||||
return ts == null ? null : convertFromDate(ts);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bind(DataBind b, MonthDay value) throws SQLException {
|
||||
if (value == null) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.avaje.ebean.text.json.EJson;
|
||||
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;
|
||||
@@ -96,19 +95,16 @@ public class ScalarTypePostgresHstore extends ScalarTypeBase<Map> {
|
||||
if (!dataInput.readBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
String json = dataInput.readUTF();
|
||||
return parse(json);
|
||||
return parse(dataInput.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, Map v) throws IOException {
|
||||
if (v == null) {
|
||||
public void writeData(DataOutput dataOutput, Map map) throws IOException {
|
||||
if (map == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
String json = format(v);
|
||||
dataOutput.writeUTF(json);
|
||||
ScalarHelp.writeUTF(dataOutput, format(map));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -46,8 +45,8 @@ public class ScalarTypeString extends ScalarTypeBase<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatValue(String t) {
|
||||
return t;
|
||||
public String formatValue(String value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.type;
|
||||
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.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -135,12 +134,10 @@ public class ScalarTypeUUIDBinary extends ScalarTypeBase<UUID> {
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, UUID value) throws IOException {
|
||||
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(format(value));
|
||||
ScalarHelp.writeUTF(dataOutput, format(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,11 @@ public class ScalarTypeUUIDNative extends ScalarTypeBase<UUID> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutput dataOutput, UUID v) throws IOException {
|
||||
if (v == null) {
|
||||
public void writeData(DataOutput dataOutput, UUID value) throws IOException {
|
||||
if (value == null) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
String json = format(v);
|
||||
dataOutput.writeUTF(json);
|
||||
ScalarHelp.writeUTF(dataOutput, format(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +104,7 @@ public class ScalarTypeUUIDNative extends ScalarTypeBase<UUID> {
|
||||
|
||||
@Override
|
||||
public UUID jsonRead(JsonParser parser) throws IOException {
|
||||
String strValue = parser.getValueAsString();
|
||||
return strValue == null ? null : parse(strValue);
|
||||
return parse(parser.getValueAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,14 +45,11 @@ public class ScalarTypeUtilDate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(DataBind b, java.util.Date value)
|
||||
throws SQLException {
|
||||
public void bind(DataBind dataBind, java.util.Date value) throws SQLException {
|
||||
if (value == null) {
|
||||
b.setNull(Types.TIMESTAMP);
|
||||
dataBind.setNull(Types.TIMESTAMP);
|
||||
} else {
|
||||
|
||||
Timestamp timestamp = new Timestamp(value.getTime());
|
||||
b.setTimestamp(timestamp);
|
||||
dataBind.setTimestamp(new Timestamp(value.getTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +70,8 @@ public class ScalarTypeUtilDate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp convertToTimestamp(Date t) {
|
||||
return new Timestamp(t.getTime());
|
||||
public Timestamp convertToTimestamp(Date date) {
|
||||
return new Timestamp(date.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,8 +98,8 @@ public class ScalarTypeUtilDate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.sql.Date convertToDate(Date t) {
|
||||
return new java.sql.Date(t.getTime());
|
||||
public java.sql.Date convertToDate(Date date) {
|
||||
return new java.sql.Date(date.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.avaje.ebean.config.ScalarTypeConverter;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user