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

com.jelastic.api.users.response.PolicyResponse Maven / Gradle / Ivy

The newest version!
/*Server class MD5: 067af5923b05fc37c1804d19c532d93e*/
package com.jelastic.api.users.response;

import com.jelastic.api.Response;
import com.jelastic.api.core.persistence.entity.Policy;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @name Jelastic API Client
 * @version 8.11.2
 * @copyright Jelastic, Inc.
 */
public class PolicyResponse extends Response {

    private static final String POLICY_KEY = "policy";

    private Policy policy;

    public PolicyResponse(Policy policy) {
        super(Response.OK());
        this.policy = policy;
    }

    public PolicyResponse(int result, String error) {
        super(result, error);
    }

    public Policy getPolicy() {
        return policy;
    }

    public void setPolicy(Policy policy) {
        this.policy = policy;
    }

    @Override
    public JSONObject _toJSON() throws JSONException {
        JSONObject json = super._toJSON();
        if (policy != null) {
            json.put(POLICY_KEY, policy.toJSON());
        }
        return json;
    }

    @Override
    public PolicyResponse _fromJSON(JSONObject jsonObject) throws JSONException {
        super._fromJSON(jsonObject);
        if (jsonObject.has(POLICY_KEY)) {
            this.policy = new Policy().fromJSON(jsonObject.getJSONObject(POLICY_KEY));
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy