Package io.protostuff

Interface Schema<T>

    • Method Summary

      All Methods Instance Methods Abstract 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.
    • Method Detail

      • getFieldName

        java.lang.String getFieldName​(int number)
        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);
         
      • getFieldNumber

        int getFieldNumber​(java.lang.String name)
        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);
         
      • isInitialized

        boolean isInitialized​(T message)
        Returns true if there is no required field or if all the required fields are set.
      • newMessage

        T newMessage()
        Creates the message/object tied to this schema.
      • messageName

        java.lang.String messageName()
        Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();
      • messageFullName

        java.lang.String messageFullName()
        Returns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName();
      • typeClass

        java.lang.Class<? super T> typeClass()
        Gets the class of the message.
      • mergeFrom

        void mergeFrom​(Input input,
                       T message)
                throws java.io.IOException
        Deserializes a message/object from the input.
        Throws:
        java.io.IOException
      • writeTo

        void writeTo​(Output output,
                     T message)
              throws java.io.IOException
        Serializes a message/object to the output.
        Throws:
        java.io.IOException