Package com.bazaarvoice.commons.data.dao.json.schema

Source Code of com.bazaarvoice.commons.data.dao.json.schema.JSONSchemaPatternPropertyMarshaller

package com.bazaarvoice.commons.data.dao.json.schema;

import com.bazaarvoice.commons.data.dao.json.AbstractMappingJSONMarshaller;
import com.bazaarvoice.commons.data.model.json.schema.JSONSchemaPatternProperty;
import org.json.JSONException;
import org.json.JSONObject;

public class JSONSchemaPatternPropertyMarshaller extends AbstractMappingJSONMarshaller<JSONSchemaPatternProperty> {
    private JSONSchemaMarshaller _jsonSchemaMarshaller;

    public JSONSchemaPatternPropertyMarshaller(JSONSchemaMarshaller jsonSchemaMarshaller) {
        _jsonSchemaMarshaller = jsonSchemaMarshaller;
    }

    @Override
    public JSONObject toJSONObject(JSONSchemaPatternProperty patternProperty)
            throws JSONException {
        return _jsonSchemaMarshaller.toJSONObject(patternProperty.getValueSchema(), false);
    }

    @Override
    protected String getKey(JSONSchemaPatternProperty patternProperty) {
        return patternProperty.getPattern();
    }

    @Override
    public JSONSchemaPatternProperty fromJSONObject(JSONObject jsonObject)
            throws JSONException {
        return new JSONSchemaPatternProperty().valueSchema(_jsonSchemaMarshaller.fromJSONObject(jsonObject));
    }

    @Override
    protected JSONSchemaPatternProperty setKey(JSONSchemaPatternProperty patternProperty, String key) {
        return patternProperty.pattern(key);
    }
}
TOP

Related Classes of com.bazaarvoice.commons.data.dao.json.schema.JSONSchemaPatternPropertyMarshaller

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.