Package com.alibaba.fastjson2.writer
Class FieldWriterObject<T>
- java.lang.Object
-
- com.alibaba.fastjson2.writer.FieldWriter<T>
-
- com.alibaba.fastjson2.writer.FieldWriterObject<T>
-
- All Implemented Interfaces:
Comparable
public class FieldWriterObject<T> extends FieldWriter<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanwriteUsing-
Fields inherited from class com.alibaba.fastjson2.writer.FieldWriter
decimalFormat, features, field, fieldClass, fieldName, fieldOffset, fieldType, format, label, method, ordinal, primitive
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectWritergetInitWriter()ObjectWritergetObjectWriter(JSONWriter jsonWriter, Class valueClass)booleanisTypeMatch(Class valueClass)Whether a value ofvalueClassis compatible with the writer cached forinitValueClass.booleanunwrapped()booleanwrite(JSONWriter jsonWriter, T object)voidwriteValue(JSONWriter jsonWriter, T object)protected booleanwriteWithUnwrapped(JSONWriter jsonWriter, Object value, long features, boolean refDetect, ObjectWriter valueWriter)-
Methods inherited from class com.alibaba.fastjson2.writer.FieldWriter
compareTo, getFieldValue, getItemClass, getItemType, getItemWriter, getPath, getRootParentPath, isDateFormatISO8601, isDateFormatMillis, isFieldClassSerializable, toString, writeBinary, writeBool, writeBool, writeDate, writeDate, writeDate, writeDouble, writeDouble, writeDouble, writeEnum, writeEnumJSONB, writeFieldName, writeFloat, writeFloat, writeFloatNull, writeInt16, writeInt32, writeInt64, writeIntNull, writeList, writeListJSONB, writeListStr, writeListValue, writeListValueJSONB, writeString, writeString
-
-
-
-
Method Detail
-
getInitWriter
public ObjectWriter getInitWriter()
- Overrides:
getInitWriterin classFieldWriter<T>
-
unwrapped
public boolean unwrapped()
- Overrides:
unwrappedin classFieldWriter<T>
-
getObjectWriter
public ObjectWriter getObjectWriter(JSONWriter jsonWriter, Class valueClass)
- Overrides:
getObjectWriterin classFieldWriter<T>
-
isTypeMatch
public boolean isTypeMatch(Class valueClass)
Whether a value ofvalueClassis compatible with the writer cached forinitValueClass. Mirrors the typeMatch check performed on the write path so thatObjectWriterAdapter.toJSONObject(Object)keepstoJSONconsistent withtoJSONString. Notably this requires an exact class match (plus the writeUsing / Map / List / primitive-boxing exceptions), so a subclass value does NOT match and must be re-resolved by its actual class to avoid silently dropping the subclass fields. ReturnsfalsewheninitValueClassisnull(no value has been observed for this field yet, so nothing is cached to match against).
-
write
public boolean write(JSONWriter jsonWriter, T object)
- Specified by:
writein classFieldWriter<T>
-
writeWithUnwrapped
protected final boolean writeWithUnwrapped(JSONWriter jsonWriter, Object value, long features, boolean refDetect, ObjectWriter valueWriter)
-
writeValue
public void writeValue(JSONWriter jsonWriter, T object)
- Specified by:
writeValuein classFieldWriter<T>
-
-