rename method
This commit is contained in:
parent
1241c64d3e
commit
4d1ae5acf4
8 changed files with 16 additions and 14 deletions
|
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
|||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ListSerializer<E> extends StdSerializer<ContiguousList<E>> {
|
||||
|
||||
|
|
@ -17,7 +18,6 @@ public class ListSerializer<E> extends StdSerializer<ContiguousList<E>> {
|
|||
public void serialize(
|
||||
ContiguousList<E> value, JsonGenerator jgen, SerializerProvider provider)
|
||||
throws IOException, JsonProcessingException {
|
||||
|
||||
// value.
|
||||
|
||||
// jgen.writeStartObject();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class BigDecimalHandler extends BuiltinTypeHandler<BigDecimal> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
return new BigDecimal((String) value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class BigIntegerHandler extends BuiltinTypeHandler<BigInteger> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
return new BigInteger((String) value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public abstract class BuiltinTypeHandler<T> extends TypeHandler {
|
|||
*/
|
||||
public void setValue(Object instance, Object value) {
|
||||
try {
|
||||
setter.invokeWithArguments(instance, transform(value));
|
||||
setter.invokeWithArguments(instance, cast(value));
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
@ -64,13 +64,13 @@ public abstract class BuiltinTypeHandler<T> extends TypeHandler {
|
|||
* Certain types can easily be stored as another known type, for instance
|
||||
* a BigDecimal can be stored as a String.
|
||||
* <p>
|
||||
* The {@link BuiltinTypeHandler} for BigDecimal would in that case be responsible for turning the String
|
||||
* into a BigDecimal. It can do that by overriding this method
|
||||
* The {@link BuiltinTypeHandler} for BigDecimal would in that case be responsible for casting the String
|
||||
* into a BigDecimal. It can do that by overriding this method.
|
||||
*
|
||||
* @param value raw value to transform to the desired output type
|
||||
* @return the transformed object
|
||||
*/
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class ByteHandler extends BuiltinTypeHandler<Byte> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
if (value instanceof Long) {
|
||||
return ((Long) value).byteValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class IntegerHandler extends BuiltinTypeHandler<Integer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
// could be Long (raw value)
|
||||
// or Integer when it's a property with known type
|
||||
if (value instanceof Long) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ShortHandler extends BuiltinTypeHandler<Short> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object transform(Object value) {
|
||||
public Object cast(Object value) {
|
||||
if (value instanceof Long) {
|
||||
return ((Long) value).shortValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ package nl.sanderhautvast.contiguous;
|
|||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
/*
|
||||
* ok, sorry
|
||||
/**
|
||||
* Abstract basertype over handlers for 'primitives' (ie. long, but also Long,
|
||||
* String..=> built-in types) and compound types (your own).
|
||||
*
|
||||
* I needed to abstract over handlers for 'primitives' (ie. long, but also Long, String..=> built-in types) and compound types (your own)
|
||||
* So this is the common ancestor. The respective functions are completely different.
|
||||
* Common ancestor primarily to iterator over properties of any type.
|
||||
* The respective functions are completely different though, and we need `instanceof` to check for the
|
||||
* actual type. (Rust enums!)
|
||||
*/
|
||||
public abstract class TypeHandler {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue