Interface DataTranslator<T>

  • Type Parameters:
    T - The type of object that this translator can handle

    public interface DataTranslator<T>
    A compatibility object to translate and translate any type of Object that is not a DataSerializable. Natively, DataView will attempt to locate a DataTranslator during DataView.set(DataQuery, Object).
    • Method Detail

      • token

        io.leangen.geantyref.TypeToken<T> token()
        Gets the TypeToken of this translator.
        Returns:
        The type token for this translator
        See Also:
        TypeToken
      • translate

        T translate​(DataView view)
             throws InvalidDataException
        Attempts to translate the T object from the provided DataView.
        Parameters:
        view - The data view to translate the object from
        Returns:
        The deserialized object
        Throws:
        InvalidDataException - If the dataview contained invalid data
      • addTo

        default DataView addTo​(T obj,
                               DataView dataView)
        Serializes the T object and applies the provided data to the provided DataView instead of creating a new DataContainer, reducing nested information.
        Parameters:
        obj - The object to serialize
        dataView - The data view to serialize to
        Returns:
        The provided data view, for chaining