public class NullSerialiser extends Object implements ToBytesSerialiser<Object>
NullSerialiser is a ToBytesSerialiser that always returns
null regardless of the input. This could be useful if properties need to be
removed.EMPTY_BYTES| Constructor and Description |
|---|
NullSerialiser() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(Class clazz)
Check whether the serialiser can serialise a particular class.
|
Object |
deserialise(byte[] bytes)
Deserialise an array of bytes into the original object.
|
Object |
deserialiseEmpty()
Handle an empty byte array and reconstruct an appropriate representation in T form.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isConsistent()
Indicates whether the serialisation process produces a predictable, consistent
OUTPUT, from a given INPUT, ie the same object should always serialise in the same way
for this to be true.
|
boolean |
preservesObjectOrdering()
Indicates whether the serialisation process preserves the ordering of the T,
i.e.
|
byte[] |
serialise(Object value)
Serialise some object and returns the raw bytes of the serialised form.
|
getClass, notify, notifyAll, toString, wait, wait, waitdeserialise, serialiseNullpublic boolean canHandle(Class clazz)
Serialiser//Warning: Due to erasure you may get false positives. e.g.
Set<Foo> set = Sets.newHashSet();
boolean b = new Serialiser<Set<Bar>, byte[]>().canHandle(set.getClass());
b will incorrectly be true because of type erasure between Set<Foo> Set<Bar>
canHandle in interface Serialiser<Object,byte[]>clazz - the object class to serialisepublic byte[] serialise(Object value) throws SerialisationException
ToBytesSerialiserserialise in interface Serialiser<Object,byte[]>serialise in interface ToBytesSerialiser<Object>value - the object to be serialisedSerialisationException - if the object fails to serialisepublic Object deserialise(byte[] bytes) throws SerialisationException
ToBytesSerialiserdeserialise in interface Serialiser<Object,byte[]>deserialise in interface ToBytesSerialiser<Object>bytes - the bytes to deserialiseSerialisationException - if the object fails to deserialise
Note that this implementation is less efficient than using deserialise with an offset and a length, but may still be used if necessary.
ToBytesSerialiser.deserialise(byte[], int, int)public Object deserialiseEmpty()
ToBytesSerialiserdeserialiseEmpty in interface Serialiser<Object,byte[]>deserialiseEmpty in interface ToBytesSerialiser<Object>public boolean preservesObjectOrdering()
ToBytesSerialiserpreservesObjectOrdering in interface Serialiser<Object,byte[]>preservesObjectOrdering in interface ToBytesSerialiser<Object>public boolean isConsistent()
SerialiserisConsistent in interface Serialiser<Object,byte[]>Copyright © 2022. All rights reserved.