Class EntitySerialiser

    • Constructor Detail

      • EntitySerialiser

        public EntitySerialiser​(Schema schema)
    • Method Detail

      • canHandle

        public boolean canHandle​(Class clazz)
        Description copied from interface: Serialiser
        Check 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:
        canHandle in interface Serialiser<Entity,​byte[]>
        Overrides:
        canHandle in class PropertiesSerialiser<Entity>
        Parameters:
        clazz - the object class to serialise
        Returns:
        boolean true if it can be handled
      • serialise

        public byte[] serialise​(Entity entity)
                         throws SerialisationException
        Description copied from interface: ToBytesSerialiser
        Serialise some object and returns the raw bytes of the serialised form.
        Parameters:
        entity - the object to be serialised
        Returns:
        byte[] the serialised bytes
        Throws:
        SerialisationException - if the object fails to serialise
      • deserialise

        public Entity deserialise​(byte[] bytes)
                           throws SerialisationException
        Description copied from interface: ToBytesSerialiser
        Deserialise 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 deserialise

        Note 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)
      • isConsistent

        public boolean isConsistent()
        Description copied from interface: Serialiser
        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.
        Returns:
        true if serialisation is consistent for a given object, otherwise false.