pt.unl.fct.di.novasys.babel.crdts.utils.datatypes

Class SerializableType

  • java.lang.Object
    • pt.unl.fct.di.novasys.babel.crdts.utils.datatypes.SerializableType
    • Constructor Detail

      • SerializableType

        public SerializableType(DataTypes dataType)
        Creates a SerializableType object and stores is concrete data type.
        Parameters:
        dataType - a PrimitiveDataType enumerator instance.
    • Method Detail

      • getDataType

        public DataTypes getDataType()
        Gets the data type of the object. This method can be used to infer the concrete data type of the object, which can be used to serialize (and deserialize) the object from the network.
        Returns:
        the data type
      • getValue

        public abstract Object getValue()
        Gets the value stored by the object.
        Returns:
        the value
      • serialize

        public abstract void serialize(io.netty.buffer.ByteBuf out)
                                throws IOException
        Throws:
        IOException
      • deserializeDataType

        public static SerializableType deserializeDataType(DataTypes dataType,
                                                           io.netty.buffer.ByteBuf in)
                                                    throws IOException
        A static method that deserializes a SerializableType by receiving it's concrete data type as an argument. The concrete serializer of the object is used based on the dataType passed into the method
        Parameters:
        dataType - data type of the object
        in - ByteBuf where the object is stored
        Returns:
        the serialized object as a SerializableType
        Throws:
        IOException - if there is an error parsing the object

Copyright © 2024. All rights reserved.