Class ObjectWriterAdapter<T>

java.lang.Object
com.alibaba.fastjson2.writer.ObjectWriterAdapter<T>
All Implemented Interfaces:
ObjectWriter<T>
Direct Known Subclasses:
ObjectWriter1, ObjectWriter10, ObjectWriter11, ObjectWriter12, ObjectWriter2, ObjectWriter3, ObjectWriter4, ObjectWriter5, ObjectWriter6, ObjectWriter7, ObjectWriter8, ObjectWriter9, ObjectWriterException, ObjectWriterRootName

public class ObjectWriterAdapter<T> extends Object implements ObjectWriter<T>
  • Field Details

    • fieldWriterArray

      protected final FieldWriter[] fieldWriterArray
    • typeName

      protected final String typeName
    • typeNameHash

      protected final long typeNameHash
    • typeNameSymbolCache

      protected long typeNameSymbolCache
    • typeNameJSONB

      protected final byte[] typeNameJSONB
  • Constructor Details

  • Method Details

    • getFeatures

      public long getFeatures()
      Description copied from interface: ObjectWriter
      Gets the features enabled by this ObjectWriter.
      Specified by:
      getFeatures in interface ObjectWriter<T>
      Returns:
      the enabled features as a bit mask
    • getFieldWriter

      public FieldWriter getFieldWriter(long hashCode)
      Description copied from interface: ObjectWriter
      Gets the FieldWriter for the specified field hash code.
      Specified by:
      getFieldWriter in interface ObjectWriter<T>
      Parameters:
      hashCode - the hash code of the field name
      Returns:
      the FieldWriter for the field, or null if not found
    • hasFilter

      public final boolean hasFilter(JSONWriter jsonWriter)
      Description copied from interface: ObjectWriter
      Checks if the JSONWriter has any filters enabled that would affect serialization.
      Specified by:
      hasFilter in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to check
      Returns:
      true if filters are enabled, false otherwise
    • hasFilter0

      protected final boolean hasFilter0(JSONWriter jsonWriter)
    • setPropertyFilter

      public void setPropertyFilter(PropertyFilter propertyFilter)
      Description copied from interface: ObjectWriter
      Sets the property filter for this ObjectWriter.
      Specified by:
      setPropertyFilter in interface ObjectWriter<T>
      Parameters:
      propertyFilter - the property filter to set
    • setValueFilter

      public void setValueFilter(ValueFilter valueFilter)
      Description copied from interface: ObjectWriter
      Sets the value filter for this ObjectWriter.
      Specified by:
      setValueFilter in interface ObjectWriter<T>
      Parameters:
      valueFilter - the value filter to set
    • setNameFilter

      public void setNameFilter(NameFilter nameFilter)
      Description copied from interface: ObjectWriter
      Sets the name filter for this ObjectWriter.
      Specified by:
      setNameFilter in interface ObjectWriter<T>
      Parameters:
      nameFilter - the name filter to set
    • setPropertyPreFilter

      public void setPropertyPreFilter(PropertyPreFilter propertyPreFilter)
      Description copied from interface: ObjectWriter
      Sets the property pre-filter for this ObjectWriter.
      Specified by:
      setPropertyPreFilter in interface ObjectWriter<T>
      Parameters:
      propertyPreFilter - the property pre-filter to set
    • writeArrayMappingJSONB

      public void writeArrayMappingJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features)
      Description copied from interface: ObjectWriter
      Writes an object to the JSONWriter in array mapping JSONB format with additional parameters.
      Specified by:
      writeArrayMappingJSONB in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to which the object should be written
      object - the object to write
      fieldName - the name of the field being written
      fieldType - the type of the field being written
      features - the features to use for writing
    • writeJSONB

      public void writeJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features)
      Description copied from interface: ObjectWriter
      Writes an object to the JSONWriter in JSONB format.
      Specified by:
      writeJSONB in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to which the object should be written
      object - the object to write
      fieldName - the name of the field being written
      fieldType - the type of the field being written
      features - the features to use for writing
    • writeClassInfo

      protected final void writeClassInfo(JSONWriter jsonWriter)
    • write

      public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features)
      Description copied from interface: ObjectWriter
      Writes an object to the JSONWriter with the given field name, field type, and features.
      Specified by:
      write in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to which the object should be written
      object - the object to write
      fieldName - the name of the field being written
      fieldType - the type of the field being written
      features - the features to use for writing
    • toMap

      public Map<String,Object> toMap(Object object)
    • getFieldWriters

      public List<FieldWriter> getFieldWriters()
      Description copied from interface: ObjectWriter
      Gets the list of FieldWriters associated with this ObjectWriter.
      Specified by:
      getFieldWriters in interface ObjectWriter<T>
      Returns:
      the list of FieldWriters, or an empty list if none are available
    • writeTypeInfo

      public boolean writeTypeInfo(JSONWriter jsonWriter)
      Description copied from interface: ObjectWriter
      Writes type information to the JSON output. This is used for polymorphic serialization to include type information in the JSON output.
      Specified by:
      writeTypeInfo in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to which type information should be written
      Returns:
      true if type information was written, false otherwise
    • writeWithFilter

      public void writeWithFilter(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features)
      Description copied from interface: ObjectWriter
      Writes an object to the JSONWriter with filter support.
      Specified by:
      writeWithFilter in interface ObjectWriter<T>
      Parameters:
      jsonWriter - the JSONWriter to which the object should be written
      object - the object to write
      fieldName - the name of the field being written
      fieldType - the type of the field being written
      features - the features to use for writing
    • toJSONObject

      public JSONObject toJSONObject(T object)
    • toJSONObject

      public JSONObject toJSONObject(T object, long features)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • errorOnNoneSerializable

      protected void errorOnNoneSerializable()