shade.com.alibaba.fastjson2.writer.FieldWriterMillisFunc Maven / Gradle / Ivy
package com.alibaba.fastjson2.writer;
import com.alibaba.fastjson2.JSONWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.function.ToLongFunction;
final class FieldWriterMillisFunc
extends FieldWriterDate {
final ToLongFunction function;
FieldWriterMillisFunc(String fieldName,
int ordinal,
long features,
String dateTimeFormat,
String label,
Field field,
Method method,
ToLongFunction function
) {
super(fieldName, ordinal, features, dateTimeFormat, label, long.class, long.class, field, method);
this.function = function;
}
@Override
public Object getFieldValue(T object) {
return function.applyAsLong(object);
}
@Override
public boolean write(JSONWriter jsonWriter, T object) {
long millis = function.applyAsLong(object);
writeDate(jsonWriter, millis);
return true;
}
@Override
public void writeValue(JSONWriter jsonWriter, T object) {
long millis = function.applyAsLong(object);
writeDate(jsonWriter, false, millis);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy