Class TargetTypeEncoder

    • Constructor Detail

      • TargetTypeEncoder

        public TargetTypeEncoder()
    • Method Detail

      • getDescriptorCode

        public UnsignedLong getDescriptorCode()
        Returns:
        the UnsignedLong value to use as the Descriptor for this type.
      • getDescriptorSymbol

        public Symbol getDescriptorSymbol()
        Returns:
        the Symbol value to use as the Descriptor for this type.
      • getTypeClass

        public Class<Target> getTypeClass()
        Returns:
        the Class type that this encoder handles.
      • writeElement

        public void writeElement​(Target target,
                                 int index,
                                 ProtonBuffer buffer,
                                 Encoder encoder,
                                 EncoderState state)
        Description copied from class: AbstractDescribedListTypeEncoder
        Instructs the encoder to write the element identified with the given index
        Specified by:
        writeElement in class AbstractDescribedListTypeEncoder<Target>
        Parameters:
        target - the source of the list elements to write
        index - the element index that needs to be written
        buffer - the buffer to write the element to
        encoder - the current Encoder value to use.
        state - the current EncoderState value to use.
      • getListEncoding

        public byte getListEncoding​(Target value)
        Description copied from class: AbstractDescribedListTypeEncoder
        Determine the list type the given value can be encoded to based on the number of bytes that would be needed to hold the encoded form of the resulting list entries.

        Most encoders will return LIST32 but for cases where the type is known to be encoded to LIST8 or always encodes an empty list (LIST0) the encoder can optimize the encode step and not compute sizes.

        Overrides:
        getListEncoding in class AbstractDescribedListTypeEncoder<Target>
        Parameters:
        value - The value that is to be encoded.
        Returns:
        the encoding code of the list type encoding needed for this object.