shade.com.alibaba.fastjson2.reader.FieldReaderInt32ValueField Maven / Gradle / Ivy
package com.alibaba.fastjson2.reader;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.schema.JSONSchema;
import com.alibaba.fastjson2.util.TypeUtils;
import java.lang.reflect.Field;
import static com.alibaba.fastjson2.util.JDKUtils.UNSAFE;
class FieldReaderInt32ValueField
extends FieldReaderObjectField {
FieldReaderInt32ValueField(String fieldName, Class fieldType, int ordinal, String format, Integer defaultValue, JSONSchema schema, Field field) {
super(fieldName, fieldType, fieldType, ordinal, 0, format, defaultValue, schema, field);
}
@Override
public void readFieldValue(JSONReader jsonReader, T object) {
int fieldInt = jsonReader.readInt32Value();
if (schema != null) {
schema.assertValidate(fieldInt);
}
UNSAFE.putInt(object, fieldOffset, fieldInt);
}
@Override
public void readFieldValueJSONB(JSONReader jsonReader, T object) {
int fieldInt = jsonReader.readInt32Value();
accept(object, fieldInt);
}
@Override
public void accept(T object, float value) {
accept(object, Integer.valueOf((int) value));
}
@Override
public void accept(T object, double value) {
accept(object, Integer.valueOf((int) value));
}
@Override
public void accept(T object, Object value) {
int intValue = TypeUtils.toIntValue(value);
if (schema != null) {
schema.assertValidate(intValue);
}
UNSAFE.putInt(object, fieldOffset, intValue);
}
@Override
public void accept(T object, long value) {
if (schema != null) {
schema.assertValidate(value);
}
int intValue = (int) value;
UNSAFE.putInt(object, fieldOffset, intValue);
}
@Override
public Object readFieldValue(JSONReader jsonReader) {
return jsonReader.readInt32Value();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy