Package io.protostuff

Class CustomSchema<T>

  • All Implemented Interfaces:
    Schema<T>

    public abstract class CustomSchema<T>
    extends java.lang.Object
    implements Schema<T>
    A schema (helper class) that wraps another schema and allows its subclasses to override certain methods for more customization.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Schema<T> schema  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFieldName​(int number)
      Gets the field name associated with the number.
      int getFieldNumber​(java.lang.String name)
      Gets the field number associated with the name.
      boolean isInitialized​(T message)
      Returns true if there is no required field or if all the required fields are set.
      void mergeFrom​(Input input, T message)
      Deserializes a message/object from the input.
      java.lang.String messageFullName()
      Returns the full name of the message tied to this schema.
      java.lang.String messageName()
      Returns the simple name of the message tied to this schema.
      T newMessage()
      Creates the message/object tied to this schema.
      java.lang.Class<? super T> typeClass()
      Gets the class of the message.
      void writeTo​(Output output, T message)
      Serializes a message/object to the output.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • schema

        protected final Schema<T> schema
    • Constructor Detail

      • CustomSchema

        public CustomSchema​(Schema<T> schema)
    • Method Detail

      • getFieldName

        public java.lang.String getFieldName​(int number)
        Description copied from interface: Schema
        Gets the field name associated with the number. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:
         return String.valueOf(number);
         
        Specified by:
        getFieldName in interface Schema<T>
      • getFieldNumber

        public int getFieldNumber​(java.lang.String name)
        Description copied from interface: Schema
        Gets the field number associated with the name. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:
         return Integer.parseInt(name);
         
        Specified by:
        getFieldNumber in interface Schema<T>
      • isInitialized

        public boolean isInitialized​(T message)
        Description copied from interface: Schema
        Returns true if there is no required field or if all the required fields are set.
        Specified by:
        isInitialized in interface Schema<T>
      • mergeFrom

        public void mergeFrom​(Input input,
                              T message)
                       throws java.io.IOException
        Description copied from interface: Schema
        Deserializes a message/object from the input.
        Specified by:
        mergeFrom in interface Schema<T>
        Throws:
        java.io.IOException
      • messageFullName

        public java.lang.String messageFullName()
        Description copied from interface: Schema
        Returns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName();
        Specified by:
        messageFullName in interface Schema<T>
      • messageName

        public java.lang.String messageName()
        Description copied from interface: Schema
        Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();
        Specified by:
        messageName in interface Schema<T>
      • newMessage

        public T newMessage()
        Description copied from interface: Schema
        Creates the message/object tied to this schema.
        Specified by:
        newMessage in interface Schema<T>
      • typeClass

        public java.lang.Class<? super T> typeClass()
        Description copied from interface: Schema
        Gets the class of the message.
        Specified by:
        typeClass in interface Schema<T>
      • writeTo

        public void writeTo​(Output output,
                            T message)
                     throws java.io.IOException
        Description copied from interface: Schema
        Serializes a message/object to the output.
        Specified by:
        writeTo in interface Schema<T>
        Throws:
        java.io.IOException