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

com.jelastic.api.system.persistence.QuotaValue Maven / Gradle / Ivy

There is a newer version: 8.12-1
Show newest version
/*Server class MD5: 7a1c714d12400492e8c430120dd9a748*/
package com.jelastic.api.system.persistence;

import com.jelastic.api.billing.response.interfaces.ArrayItem;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;

/**
 * @name Jelastic API Client
 * @version 8.11.2
 * @copyright Jelastic, Inc.
 */
public class QuotaValue extends ArrayItem implements Serializable {

    private Quota quota;

    private int value;

    private QuotaType type;

    public Quota getQuota() {
        return quota;
    }

    public void setQuota(Quota quota) {
        this.quota = quota;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public QuotaType getType() {
        return type;
    }

    public void setType(QuotaType type) {
        this.type = type;
    }

    @Override
    public QuotaValue _fromJSON(JSONObject json) throws JSONException {
        if (json.has("id")) {
            this.id = json.getInt("id");
        }
        if (json.has("type")) {
            this.type = QuotaType.valueOf(json.getString("type").toUpperCase());
        }
        if (json.has("value")) {
            this.value = json.getInt("value");
        }
        if (json.has("quota")) {
            this.quota = new Quota()._fromJSON(json.getJSONObject("quota"));
        }
        if (json.has("type")) {
            this.type = QuotaType.valueOf(json.getString("type").toUpperCase());
        }
        return this;
    }

    @Override
    public JSONObject _toJSON() throws JSONException {
        JSONObject json = new JSONObject();
        json.put("id", id);
        json.put("value", value);
        if (type != null) {
            json.put("type", this.type.name());
        }
        if (quota != null) {
            json.put("quota", quota._toJSON());
        }
        return json;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        final QuotaValue other = (QuotaValue) obj;
        if (this.quota != other.quota && (this.quota == null || !this.quota.equals(other.quota))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        return 5;
    }

    @Override
    public QuotaValue clone() {
        QuotaValue quotaValue = new QuotaValue();
        quotaValue.setQuota(quota);
        quotaValue.setValue(value);
        quotaValue.setQuota(quota);
        quotaValue.setType(type);
        return quotaValue;
    }

    public boolean equalsIgnoreCaseQuotaName(String value) {
        return quota.getName().equalsIgnoreCase(value);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy