com.clover.sdk.v3.base.Tender.java Source code

Java tutorial

Introduction

Here is the source code for com.clover.sdk.v3.base.Tender.java

Source

/**
 * Copyright (C) 2015 Clover Network, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Autogenerated by Avro
 * 
 * DO NOT EDIT DIRECTLY
 */

package com.clover.sdk.v3.base;

import com.clover.sdk.GenericClient;

@SuppressWarnings("all")
public final class Tender
        implements android.os.Parcelable, com.clover.sdk.v3.Validator, com.clover.sdk.JSONifiable {

    /**
     * Unique identifier
     */
    public java.lang.String getId() {
        return genClient.cacheGet(CacheKey.id);
    }

    /**
     * If this merchant tender is editable
     */
    public java.lang.Boolean getEditable() {
        return genClient.cacheGet(CacheKey.editable);
    }

    /**
     * Label Key
     */
    public java.lang.String getLabelKey() {
        return genClient.cacheGet(CacheKey.labelKey);
    }

    /**
     * Label Key
     */
    public java.lang.String getLabel() {
        return genClient.cacheGet(CacheKey.label);
    }

    /**
     * If this tender opens the cash drawer
     */
    public java.lang.Boolean getOpensCashDrawer() {
        return genClient.cacheGet(CacheKey.opensCashDrawer);
    }

    /**
     * Allow tipping on payment from tender
     */
    public java.lang.Boolean getSupportsTipping() {
        return genClient.cacheGet(CacheKey.supportsTipping);
    }

    /**
     * If this merchant tender is enabled
     */
    public java.lang.Boolean getEnabled() {
        return genClient.cacheGet(CacheKey.enabled);
    }

    /**
     * If this merchant tender is visible
     */
    public java.lang.Boolean getVisible() {
        return genClient.cacheGet(CacheKey.visible);
    }

    /**
     * Label Key
     */
    public java.lang.String getInstructions() {
        return genClient.cacheGet(CacheKey.instructions);
    }

    private enum CacheKey implements com.clover.sdk.ValueExtractorEnum<Tender> {
        id {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("id", java.lang.String.class);
            }
        },
        editable {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("editable", java.lang.Boolean.class);
            }
        },
        labelKey {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("labelKey", java.lang.String.class);
            }
        },
        label {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("label", java.lang.String.class);
            }
        },
        opensCashDrawer {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("opensCashDrawer", java.lang.Boolean.class);
            }
        },
        supportsTipping {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("supportsTipping", java.lang.Boolean.class);
            }
        },
        enabled {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("enabled", java.lang.Boolean.class);
            }
        },
        visible {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("visible", java.lang.Boolean.class);
            }
        },
        instructions {
            @Override
            public Object extractValue(Tender instance) {
                return instance.genClient.extractOther("instructions", java.lang.String.class);
            }
        },;
    }

    private GenericClient<Tender> genClient = new GenericClient<Tender>(this);

    /**
     * Constructs a new empty instance.
     */
    public Tender() {
    }

    /**
     * Constructs a new instance from the given JSON String.
     */
    public Tender(String json) throws IllegalArgumentException {
        try {
            genClient.setJsonObject(new org.json.JSONObject(json));
        } catch (org.json.JSONException e) {
            throw new IllegalArgumentException("invalid json", e);
        }
    }

    /**
     * Construct a new instance backed by the given JSONObject, the parameter is not copied so changes to it will be
     * reflected in this instance and vice-versa.
     */
    public Tender(org.json.JSONObject jsonObject) {
        genClient.setJsonObject(jsonObject);
    }

    /**
     * Constructs a new instance that is a deep copy of the source instance. It does not copy the bundle or changelog.
     */
    public Tender(Tender src) {
        if (src.genClient.getJsonObject() != null) {
            genClient.setJsonObject(com.clover.sdk.v3.JsonHelper.deepCopy(src.genClient.getJSONObject()));
        }
    }

    /**
     * Returns the internal JSONObject backing this instance, the return value is not a copy so changes to it will be
     * reflected in this instance and vice-versa.
     */
    public org.json.JSONObject getJSONObject() {
        return genClient.getJSONObject();
    }

    @Override
    public void validate() {
        genClient.validateLength(getId(), 13);

        genClient.validateLength(getLabelKey(), 127);

        genClient.validateLength(getLabel(), 127);
    }

    /** Checks whether the 'id' field is set and is not null */
    public boolean isNotNullId() {
        return genClient.cacheValueIsNotNull(CacheKey.id);
    }

    /** Checks whether the 'editable' field is set and is not null */
    public boolean isNotNullEditable() {
        return genClient.cacheValueIsNotNull(CacheKey.editable);
    }

    /** Checks whether the 'labelKey' field is set and is not null */
    public boolean isNotNullLabelKey() {
        return genClient.cacheValueIsNotNull(CacheKey.labelKey);
    }

    /** Checks whether the 'label' field is set and is not null */
    public boolean isNotNullLabel() {
        return genClient.cacheValueIsNotNull(CacheKey.label);
    }

    /** Checks whether the 'opensCashDrawer' field is set and is not null */
    public boolean isNotNullOpensCashDrawer() {
        return genClient.cacheValueIsNotNull(CacheKey.opensCashDrawer);
    }

    /** Checks whether the 'supportsTipping' field is set and is not null */
    public boolean isNotNullSupportsTipping() {
        return genClient.cacheValueIsNotNull(CacheKey.supportsTipping);
    }

    /** Checks whether the 'enabled' field is set and is not null */
    public boolean isNotNullEnabled() {
        return genClient.cacheValueIsNotNull(CacheKey.enabled);
    }

    /** Checks whether the 'visible' field is set and is not null */
    public boolean isNotNullVisible() {
        return genClient.cacheValueIsNotNull(CacheKey.visible);
    }

    /** Checks whether the 'instructions' field is set and is not null */
    public boolean isNotNullInstructions() {
        return genClient.cacheValueIsNotNull(CacheKey.instructions);
    }

    /** Checks whether the 'id' field has been set, however the value could be null */
    public boolean hasId() {
        return genClient.cacheHasKey(CacheKey.id);
    }

    /** Checks whether the 'editable' field has been set, however the value could be null */
    public boolean hasEditable() {
        return genClient.cacheHasKey(CacheKey.editable);
    }

    /** Checks whether the 'labelKey' field has been set, however the value could be null */
    public boolean hasLabelKey() {
        return genClient.cacheHasKey(CacheKey.labelKey);
    }

    /** Checks whether the 'label' field has been set, however the value could be null */
    public boolean hasLabel() {
        return genClient.cacheHasKey(CacheKey.label);
    }

    /** Checks whether the 'opensCashDrawer' field has been set, however the value could be null */
    public boolean hasOpensCashDrawer() {
        return genClient.cacheHasKey(CacheKey.opensCashDrawer);
    }

    /** Checks whether the 'supportsTipping' field has been set, however the value could be null */
    public boolean hasSupportsTipping() {
        return genClient.cacheHasKey(CacheKey.supportsTipping);
    }

    /** Checks whether the 'enabled' field has been set, however the value could be null */
    public boolean hasEnabled() {
        return genClient.cacheHasKey(CacheKey.enabled);
    }

    /** Checks whether the 'visible' field has been set, however the value could be null */
    public boolean hasVisible() {
        return genClient.cacheHasKey(CacheKey.visible);
    }

    /** Checks whether the 'instructions' field has been set, however the value could be null */
    public boolean hasInstructions() {
        return genClient.cacheHasKey(CacheKey.instructions);
    }

    /**
     * Sets the field 'id'.
     */
    public Tender setId(java.lang.String id) {
        return genClient.setOther(id, CacheKey.id);
    }

    /**
     * Sets the field 'editable'.
     */
    public Tender setEditable(java.lang.Boolean editable) {
        return genClient.setOther(editable, CacheKey.editable);
    }

    /**
     * Sets the field 'labelKey'.
     */
    public Tender setLabelKey(java.lang.String labelKey) {
        return genClient.setOther(labelKey, CacheKey.labelKey);
    }

    /**
     * Sets the field 'label'.
     */
    public Tender setLabel(java.lang.String label) {
        return genClient.setOther(label, CacheKey.label);
    }

    /**
     * Sets the field 'opensCashDrawer'.
     */
    public Tender setOpensCashDrawer(java.lang.Boolean opensCashDrawer) {
        return genClient.setOther(opensCashDrawer, CacheKey.opensCashDrawer);
    }

    /**
     * Sets the field 'supportsTipping'.
     */
    public Tender setSupportsTipping(java.lang.Boolean supportsTipping) {
        return genClient.setOther(supportsTipping, CacheKey.supportsTipping);
    }

    /**
     * Sets the field 'enabled'.
     */
    public Tender setEnabled(java.lang.Boolean enabled) {
        return genClient.setOther(enabled, CacheKey.enabled);
    }

    /**
     * Sets the field 'visible'.
     */
    public Tender setVisible(java.lang.Boolean visible) {
        return genClient.setOther(visible, CacheKey.visible);
    }

    /**
     * Sets the field 'instructions'.
     */
    public Tender setInstructions(java.lang.String instructions) {
        return genClient.setOther(instructions, CacheKey.instructions);
    }

    /** Clears the 'id' field, the 'has' method for this field will now return false */
    public void clearId() {
        genClient.clear(CacheKey.id);
    }

    /** Clears the 'editable' field, the 'has' method for this field will now return false */
    public void clearEditable() {
        genClient.clear(CacheKey.editable);
    }

    /** Clears the 'labelKey' field, the 'has' method for this field will now return false */
    public void clearLabelKey() {
        genClient.clear(CacheKey.labelKey);
    }

    /** Clears the 'label' field, the 'has' method for this field will now return false */
    public void clearLabel() {
        genClient.clear(CacheKey.label);
    }

    /** Clears the 'opensCashDrawer' field, the 'has' method for this field will now return false */
    public void clearOpensCashDrawer() {
        genClient.clear(CacheKey.opensCashDrawer);
    }

    /** Clears the 'supportsTipping' field, the 'has' method for this field will now return false */
    public void clearSupportsTipping() {
        genClient.clear(CacheKey.supportsTipping);
    }

    /** Clears the 'enabled' field, the 'has' method for this field will now return false */
    public void clearEnabled() {
        genClient.clear(CacheKey.enabled);
    }

    /** Clears the 'visible' field, the 'has' method for this field will now return false */
    public void clearVisible() {
        genClient.clear(CacheKey.visible);
    }

    /** Clears the 'instructions' field, the 'has' method for this field will now return false */
    public void clearInstructions() {
        genClient.clear(CacheKey.instructions);
    }

    /**
     * Returns true if this instance has any changes.
     */
    public boolean containsChanges() {
        return genClient.containsChanges();
    }

    /**
     * Reset the log of changes made to this instance, calling copyChanges() after this would return an empty instance.
     */
    public void resetChangeLog() {
        genClient.resetChangeLog();
    }

    /**
     * Create a copy of this instance that contains only fields that were set after the constructor was called.
     */
    public Tender copyChanges() {
        Tender copy = new Tender();
        copy.mergeChanges(this);
        copy.resetChangeLog();
        return copy;
    }

    /**
     * Copy all the changed fields from the given source to this instance.
     */
    public void mergeChanges(Tender src) {
        if (src.genClient.getChangeLog() != null) {
            genClient.mergeChanges(new Tender(src).getJSONObject(), src.genClient);
        }
    }

    /**
     * Gets a Bundle which can be used to get and set data attached to this instance. The attached Bundle will be
     * parcelled but not jsonified.
     */
    public android.os.Bundle getBundle() {
        return genClient.getBundle();
    }

    @Override
    public String toString() {
        return genClient.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(android.os.Parcel dest, int flags) {
        genClient.writeToParcel(dest, flags);
    }

    public static final android.os.Parcelable.Creator<Tender> CREATOR = new android.os.Parcelable.Creator<Tender>() {
        @Override
        public Tender createFromParcel(android.os.Parcel in) {
            Tender instance = new Tender(
                    com.clover.sdk.v3.JsonParcelHelper.ObjectWrapper.CREATOR.createFromParcel(in).unwrap());
            instance.genClient.setBundle(in.readBundle(getClass().getClassLoader()));
            instance.genClient.setChangeLog(in.readBundle());
            return instance;
        }

        @Override
        public Tender[] newArray(int size) {
            return new Tender[size];
        }
    };

    public static final com.clover.sdk.JSONifiable.Creator<Tender> JSON_CREATOR = new com.clover.sdk.JSONifiable.Creator<Tender>() {
        @Override
        public Tender create(org.json.JSONObject jsonObject) {
            return new Tender(jsonObject);
        }
    };

    public interface Constraints {

        public static final boolean ID_IS_REQUIRED = false;
        public static final long ID_MAX_LEN = 13;

        public static final boolean EDITABLE_IS_REQUIRED = false;

        public static final boolean LABELKEY_IS_REQUIRED = false;
        public static final long LABELKEY_MAX_LEN = 127;

        public static final boolean LABEL_IS_REQUIRED = false;
        public static final long LABEL_MAX_LEN = 127;

        public static final boolean OPENSCASHDRAWER_IS_REQUIRED = false;

        public static final boolean SUPPORTSTIPPING_IS_REQUIRED = false;

        public static final boolean ENABLED_IS_REQUIRED = false;

        public static final boolean VISIBLE_IS_REQUIRED = false;

        public static final boolean INSTRUCTIONS_IS_REQUIRED = false;

    }

}