Interface IndexedField

All Known Implementing Classes:
BasicInstructionField, BasicInstructionStatusField, BasicLocationField, BasicObjectDatumStreamMetadataField

public interface IndexedField
API for a JSON field that is ordered by an index value for the purposes of serialization.

This API is designed to be implemented by Enum types, to facilitate a single definition of JSON object field names and their order when serializing and deserializing a related object into/from JSON, without using reflection. See JsonUtils.parseIndexedFieldsObject(JsonParser, DeserializationContext, Object[], Map) for help in parsing JSON using this structure. The intention is that a JSON serializer and deserializer class pair would share a common Enum that implements this interface to help ensure a consistent JSON structure is used by both.

Since:
1.72
Version:
1.1
Author:
matt
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E extends Enum<E> & IndexedField>
    Map<String,E>
    fieldMap(Class<E> clazz)
    Get a mapping of field names to IndexedField instances from an enumeration that implements IndexedField.
    Get the field name.
    int
    Get the index.
    parseValue(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.databind.DeserializationContext ctxt)
    Parse a value from a parser.
    void
    writeValue(com.fasterxml.jackson.core.JsonGenerator generator, com.fasterxml.jackson.databind.SerializerProvider provider, Object value)
    Write a value to a generator.
  • Method Details

    • getIndex

      int getIndex()
      Get the index.
      Returns:
      the index
    • getFieldName

      String getFieldName()
      Get the field name.
      Returns:
      the fieldName
    • parseValue

      Object parseValue(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
      Parse a value from a parser.
      Parameters:
      parser - the parser
      ctxt - the context
      Returns:
      the parsed object
      Throws:
      IOException - if any IO error occurs
      com.fasterxml.jackson.core.JsonProcessingException - if any JSON processing error occurs
    • writeValue

      void writeValue(com.fasterxml.jackson.core.JsonGenerator generator, com.fasterxml.jackson.databind.SerializerProvider provider, Object value) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
      Write a value to a generator.
      Parameters:
      generator - the generator
      provider - the provider
      value - the value to write
      Throws:
      IOException - if any IO error occurs
      com.fasterxml.jackson.core.JsonProcessingException - if any JSON processing error occurs
    • fieldMap

      static <E extends Enum<E> & IndexedField> Map<String,E> fieldMap(Class<E> clazz)
      Get a mapping of field names to IndexedField instances from an enumeration that implements IndexedField.
      Type Parameters:
      E - the enum type
      Parameters:
      clazz - the enum class
      Returns:
      the map