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

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

The newest version!
/*Server class MD5: 73dcafb0931e0ac5b8655970bd9e4c17*/
package com.jelastic.api.system.persistence;

import com.jelastic.api.core.utils.DateUtils;
import com.jelastic.api.development.response.interfaces.ArrayItem;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date;

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

    public static final String ID = "id";

    public static final String KEY_NUMBER = "keyNumber";

    public static final String EXP_DATE = "expDate";

    public static final String STATUS = "status";

    private String keyNumber;

    private Date expDate;

    private VZLicenseStatus status;

    public VZLicense() {
    }

    public VZLicense(String keyNumber, Date expDate, VZLicenseStatus status) {
        this.keyNumber = keyNumber;
        this.expDate = expDate;
        this.status = status;
    }

    public Date getExpDate() {
        return expDate;
    }

    public void setExpDate(Date expDate) {
        this.expDate = expDate;
    }

    public String getKeyNumber() {
        return keyNumber;
    }

    public void setKeyNumber(String keyNumber) {
        this.keyNumber = keyNumber;
    }

    public VZLicenseStatus getStatus() {
        return status;
    }

    public void setStatus(VZLicenseStatus status) {
        this.status = status;
    }

    @Override
    public JSONObject _toJSON() throws JSONException {
        JSONObject json = new JSONObject();
        if (id != -1) {
            json.put(ID, id);
        }
        if (expDate != null) {
            json.put(EXP_DATE, DateUtils.formatSqlDateTime(expDate));
        }
        json.put(KEY_NUMBER, keyNumber);
        if (status != null) {
            json.put(STATUS, status.name());
        }
        return json;
    }

    @Override
    public VZLicense _fromJSON(JSONObject json) throws JSONException {
        if (json.has(ID)) {
            id = json.getInt(ID);
        }
        if (json.has(EXP_DATE)) {
            try {
                expDate = DateUtils.parseSqlDate(json.getString(EXP_DATE));
            } catch (ParseException e) {
            }
        }
        if (json.has(KEY_NUMBER)) {
            keyNumber = json.getString(KEY_NUMBER);
        }
        if (json.has(STATUS)) {
            status = VZLicenseStatus.valueOf(json.getString(STATUS));
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy