Class ElementSerialiser
- java.lang.Object
-
- uk.gov.gchq.gaffer.store.serialiser.PropertiesSerialiser<Element>
-
- uk.gov.gchq.gaffer.store.serialiser.ElementSerialiser
-
- All Implemented Interfaces:
Serializable,Serialiser<Element,byte[]>,ToBytesSerialiser<Element>
public class ElementSerialiser extends PropertiesSerialiser<Element>
Serialiser to serialise and deserialiseElementobjects in a byte array representation by delegating to the relevant serialiser.- See Also:
EdgeSerialiser,EntitySerialiser, Serialized Form
-
-
Field Summary
-
Fields inherited from interface uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser
EMPTY_BYTES
-
-
Constructor Summary
Constructors Constructor Description ElementSerialiser(Schema schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanHandle(Class clazz)Check whether the serialiser can serialise a particular class.Elementdeserialise(byte[] bytes)Deserialise an array of bytes into the original object.ElementdeserialiseEmpty()Handle an empty byte array and reconstruct an appropriate representation in T form.booleanequals(Object obj)StringgetGroup(byte[] bytes)inthashCode()booleanisConsistent()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.byte[]serialise(Element element)Serialise some object and returns the raw bytes of the serialised form.-
Methods inherited from class uk.gov.gchq.gaffer.store.serialiser.PropertiesSerialiser
preservesObjectOrdering, updateSchema
-
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser
deserialise, serialiseNull
-
-
-
-
Constructor Detail
-
ElementSerialiser
public ElementSerialiser(Schema schema)
-
-
Method Detail
-
canHandle
public boolean canHandle(Class clazz)
Description copied from interface:SerialiserCheck whether the serialiser can serialise a particular class.//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>- Specified by:
canHandlein interfaceSerialiser<Element,byte[]>- Overrides:
canHandlein classPropertiesSerialiser<Element>- Parameters:
clazz- the object class to serialise- Returns:
- boolean true if it can be handled
-
serialise
public byte[] serialise(Element element) throws SerialisationException
Description copied from interface:ToBytesSerialiserSerialise some object and returns the raw bytes of the serialised form.- Parameters:
element- the object to be serialised- Returns:
- byte[] the serialised bytes
- Throws:
SerialisationException- if the object fails to serialise
-
deserialise
public Element deserialise(byte[] bytes) throws SerialisationException
Description copied from interface:ToBytesSerialiserDeserialise an array of bytes into the original object.- Parameters:
bytes- the bytes to deserialise- Returns:
- T the deserialised object
- Throws:
SerialisationException- if the object fails to deserialiseNote that this implementation is less efficient than using deserialise with an offset and a length, but may still be used if necessary. It has been marked deprecated but will not be removed as it is needed in the Serialiser interface.
- See Also:
ToBytesSerialiser.deserialise(byte[], int, int)
-
getGroup
public String getGroup(byte[] bytes) throws SerialisationException
- Throws:
SerialisationException
-
deserialiseEmpty
public Element deserialiseEmpty() throws SerialisationException
Description copied from interface:ToBytesSerialiserHandle an empty byte array and reconstruct an appropriate representation in T form.- Returns:
- T the deserialised object
- Throws:
SerialisationException- if the object fails to deserialise
-
isConsistent
public boolean isConsistent()
Description copied from interface:SerialiserIndicates 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.- Returns:
- true if serialisation is consistent for a given object, otherwise false.
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classPropertiesSerialiser<Element>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classPropertiesSerialiser<Element>
-
-