All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wizzardo.tools.json.JsonFieldInfo Maven / Gradle / Ivy

The newest version!
package com.wizzardo.tools.json;

import com.wizzardo.tools.reflection.FieldInfo;

import java.lang.reflect.Field;
import java.util.Map;

/**
 * Created by wizzardo on 14/07/16.
 */
public class JsonFieldInfo extends FieldInfo {
    public final Binder.Serializer serializer;
    protected String preparedFieldName;

    public JsonFieldInfo(Field field, JsonFieldSetter reflection, JsonGeneric generic, Binder.Serializer serializer) {
        super(field, reflection, generic);
        this.serializer = serializer;
    }

    protected void prepareName(boolean firstField) {
        if (firstField)
            preparedFieldName = "{\"" + field.getName() + "\":";
        else
            preparedFieldName = ",\"" + field.getName() + "\":";
    }

    public String getPreparedFieldName() {
        return preparedFieldName;
    }

    @Override
    protected JsonGeneric createGeneric(Field field, Map types) {
        return new JsonGeneric(field.getGenericType(), types);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy