Class DerivativeSchema

  • All Implemented Interfaces:
    Schema<java.lang.Object>

    public abstract class DerivativeSchema
    extends java.lang.Object
    implements Schema<java.lang.Object>
    This schema delegates to another schema derived from the input.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void doMergeFrom​(Input input, Schema<java.lang.Object> derivedSchema, java.lang.Object owner)  
      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​(java.lang.Object owner)
      Returns true if there is no required field or if all the required fields are set.
      void mergeFrom​(Input input, java.lang.Object owner)
      Delegates to the schema derived 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.
      java.lang.Object newMessage()
      Creates the message/object tied to this schema.
      java.lang.Class<? super java.lang.Object> typeClass()
      Gets the class of the message.
      void writeTo​(Output output, java.lang.Object value)
      Delegates to the schema derived from the value.
      • Methods inherited from class java.lang.Object

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

      • pipeSchema

        public final Pipe.Schema<java.lang.Object> pipeSchema
        This pipe schema delegates to another schema derived from the input.
    • Constructor Detail

      • DerivativeSchema

        public DerivativeSchema​(IdStrategy strategy)
    • 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<java.lang.Object>
      • 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<java.lang.Object>
      • isInitialized

        public boolean isInitialized​(java.lang.Object owner)
        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<java.lang.Object>
      • 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<java.lang.Object>
      • 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<java.lang.Object>
      • newMessage

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

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

        public void mergeFrom​(Input input,
                              java.lang.Object owner)
                       throws java.io.IOException
        Delegates to the schema derived from the input. The owner owns the message (polymorphic) that is tied to this schema.
        Specified by:
        mergeFrom in interface Schema<java.lang.Object>
        Throws:
        java.io.IOException
      • writeTo

        public void writeTo​(Output output,
                            java.lang.Object value)
                     throws java.io.IOException
        Delegates to the schema derived from the value.
        Specified by:
        writeTo in interface Schema<java.lang.Object>
        Throws:
        java.io.IOException
      • doMergeFrom

        protected abstract void doMergeFrom​(Input input,
                                            Schema<java.lang.Object> derivedSchema,
                                            java.lang.Object owner)
                                     throws java.io.IOException
        Throws:
        java.io.IOException