Class ReaderWriterModifier

java.lang.Object
com.fasterxml.jackson.jr.ob.api.ReaderWriterModifier
Direct Known Subclasses:
ReaderWriterModifier.Pair

public abstract class ReaderWriterModifier extends Object
API to implement to apply modifications to ValueReaders and ValueWriters of all kinds (default scalar ones, custom ones, POJO ones).
Since:
2.11
  • Constructor Details

    • ReaderWriterModifier

      public ReaderWriterModifier()
  • Method Details

    • pojoDefinitionForDeserialization

      public POJODefinition pojoDefinitionForDeserialization(JSONReader readContext, Class<?> pojoType)
    • pojoDefinitionForSerialization

      public POJODefinition pojoDefinitionForSerialization(JSONWriter writeContext, Class<?> pojoType)
    • modifyValueReader

      public ValueReader modifyValueReader(JSONReader readContext, Class<?> type, ValueReader defaultReader)
      Method called after ValueReader to use has been constructed, but before it is to be used for the first time. Method may either return that reader as-is, or construct a different ValueReader and return that to be used.

      This method is often used to create a new ValueReader that needs to delegate to the original reader for some uses, but not all.

      Parameters:
      readContext - Context that may be used to access configuration
      type - Type of values to read
      defaultReader - ValueReader that is to be used
      Returns:
      either defaultReader as-is, or an alternate ValueReader to use.
    • modifyValueWriter

      public ValueWriter modifyValueWriter(JSONWriter writeContext, Class<?> type, ValueWriter defaultWriter)
      Method called after ValueWriter to use has been constructed, but before it is to be used for the first time. Method may either return that writer as-is, or construct a different ValueWriter and return that to be used.

      Note that this method is NOT called for non-POJO JDK "standard" values that jackson-jr supports (such as Numbers, String and URL); for these types, overrideStandardValueWriter(com.fasterxml.jackson.jr.ob.impl.JSONWriter, java.lang.Class<?>, int) is called instead.

      This method is often used to create a new ValueReader that needs to delegate to the original reader for some uses, but not all.

      Parameters:
      writeContext - Context that may be used to access configuration
      type - Type of values to write
      defaultWriter - ValueReader that is to be used
      Returns:
      either defaultReader as-is, or an alternate ValueWriter to use; must not return null.
    • overrideStandardValueWriter

      public ValueWriter overrideStandardValueWriter(JSONWriter writeContext, Class<?> type, int stdTypeId)
      Method called instead of modifyValueWriter(com.fasterxml.jackson.jr.ob.impl.JSONWriter, java.lang.Class<?>, com.fasterxml.jackson.jr.ob.api.ValueWriter) for set of non-POJO "standard" JDK types that do not have matching ValueWriter and are normally directly serialized by JSONWriter itself. Handler may either return null to indicate "no override" or return custom ValueWriter to use.
      Parameters:
      writeContext - Context that may be used to access configuration
      type - Type of values to write
      stdTypeId - Internal identifier of standard type (not usually useful, but could potentially be used for delegating)
      Returns:
      null if no override should occur, or ValueWriter to use.