shade.com.alibaba.fastjson2.writer.ObjectWriters Maven / Gradle / Ivy
package com.alibaba.fastjson2.writer;
import com.alibaba.fastjson2.codec.FieldInfo;
import com.alibaba.fastjson2.function.ToByteFunction;
import com.alibaba.fastjson2.function.ToFloatFunction;
import com.alibaba.fastjson2.function.ToShortFunction;
import com.alibaba.fastjson2.util.ParameterizedTypeImpl;
import com.alibaba.fastjson2.util.TypeUtils;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.List;
import java.util.function.*;
public class ObjectWriters {
static final ObjectWriterCreator INSTANCE = ObjectWriterCreator.INSTANCE;
public static ObjectWriter ofReflect(Class objectType) {
return ObjectWriterCreator.INSTANCE.createObjectWriter(objectType);
}
public static ObjectWriter objectWriter(Class objectType) {
return INSTANCE.createObjectWriter(objectType);
}
public static ObjectWriter objectWriter(Class objectType, FieldWriter... fieldWriters) {
return INSTANCE.createObjectWriter(objectType, fieldWriters);
}
public static ObjectWriter of(Class objectType, FieldWriter... fieldWriters) {
return INSTANCE.createObjectWriter(objectType, fieldWriters);
}
public static ObjectWriter objectWriter(Class objectType, long features, FieldWriter... fieldWriters) {
return INSTANCE.createObjectWriter(objectType, features, fieldWriters);
}
public static ObjectWriter objectWriter(FieldWriter... fieldWriters) {
return INSTANCE.createObjectWriter(fieldWriters);
}
public static ObjectWriter ofToString(Function function) {
return INSTANCE.createObjectWriter(
INSTANCE.createFieldWriter(
null,
null,
"toString",
0,
FieldInfo.VALUE_MASK,
null,
null,
String.class,
String.class,
null,
function
)
);
}
public static ObjectWriter ofToInt(ToIntFunction function) {
return INSTANCE.createObjectWriter(
new FieldWriterInt32ValFunc(
"toInt",
0,
FieldInfo.VALUE_MASK,
null,
null,
null,
null,
function
)
);
}
public static ObjectWriter ofToLong(ToLongFunction function) {
return INSTANCE.createObjectWriter(
new FieldWriterInt64ValFunc(
"toLong",
0,
FieldInfo.VALUE_MASK,
null,
null,
null,
null,
function
)
);
}
public static ObjectWriter ofToByteArray(Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy