com.clover.sdk.v3.payments.Credit.java Source code

Java tutorial

Introduction

Here is the source code for com.clover.sdk.v3.payments.Credit.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.payments;

import com.clover.sdk.GenericClient;

@SuppressWarnings("all")
public final class Credit
        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);
    }

    /**
     * The order with which the credit is associated
     */
    public com.clover.sdk.v3.base.Reference getOrderRef() {
        return genClient.cacheGet(CacheKey.orderRef);
    }

    /**
     * Device which processed this credit
     */
    public com.clover.sdk.v3.base.Reference getDevice() {
        return genClient.cacheGet(CacheKey.device);
    }

    /**
     * The tender type associated with this payment, e.g. credit card, cash, etc.
     */
    public com.clover.sdk.v3.base.Tender getTender() {
        return genClient.cacheGet(CacheKey.tender);
    }

    /**
     * The employee who processed the payment
     */
    public com.clover.sdk.v3.base.Reference getEmployee() {
        return genClient.cacheGet(CacheKey.employee);
    }

    /**
     * Customer who received the credit/refund
     */
    public com.clover.sdk.v3.customers.Customer getCustomers() {
        return genClient.cacheGet(CacheKey.customers);
    }

    /**
     * Amount paid in tax
     */
    public java.lang.Long getAmount() {
        return genClient.cacheGet(CacheKey.amount);
    }

    /**
     * Amount paid in tax
     */
    public java.lang.Long getTaxAmount() {
        return genClient.cacheGet(CacheKey.taxAmount);
    }

    public java.util.List<com.clover.sdk.v3.payments.TaxableAmountRate> getTaxRates() {
        return genClient.cacheGet(CacheKey.taxRates);
    }

    /**
     * Time payment was recorded on server
     */
    public java.lang.Long getCreatedTime() {
        return genClient.cacheGet(CacheKey.createdTime);
    }

    public java.lang.Long getClientCreatedTime() {
        return genClient.cacheGet(CacheKey.clientCreatedTime);
    }

    /**
     * Information about the card used for credit/debit card payments
     */
    public com.clover.sdk.v3.payments.CardTransaction getCardTransaction() {
        return genClient.cacheGet(CacheKey.cardTransaction);
    }

    private enum CacheKey implements com.clover.sdk.ValueExtractorEnum<Credit> {
        id {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractOther("id", java.lang.String.class);
            }
        },
        orderRef {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("orderRef", com.clover.sdk.v3.base.Reference.JSON_CREATOR);
            }
        },
        device {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("device", com.clover.sdk.v3.base.Reference.JSON_CREATOR);
            }
        },
        tender {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("tender", com.clover.sdk.v3.base.Tender.JSON_CREATOR);
            }
        },
        employee {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("employee", com.clover.sdk.v3.base.Reference.JSON_CREATOR);
            }
        },
        customers {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("customers",
                        com.clover.sdk.v3.customers.Customer.JSON_CREATOR);
            }
        },
        amount {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractOther("amount", java.lang.Long.class);
            }
        },
        taxAmount {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractOther("taxAmount", java.lang.Long.class);
            }
        },
        taxRates {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractListRecord("taxRates",
                        com.clover.sdk.v3.payments.TaxableAmountRate.JSON_CREATOR);
            }
        },
        createdTime {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractOther("createdTime", java.lang.Long.class);
            }
        },
        clientCreatedTime {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractOther("clientCreatedTime", java.lang.Long.class);
            }
        },
        cardTransaction {
            @Override
            public Object extractValue(Credit instance) {
                return instance.genClient.extractRecord("cardTransaction",
                        com.clover.sdk.v3.payments.CardTransaction.JSON_CREATOR);
            }
        },;
    }

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

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

    /**
     * Constructs a new instance from the given JSON String.
     */
    public Credit(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 Credit(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 Credit(Credit 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);
    }

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

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

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

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

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

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

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

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

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

    /** Checks whether the 'taxRates' field is set and is not null and is not empty */
    public boolean isNotEmptyTaxRates() {
        return isNotNullTaxRates() && !getTaxRates().isEmpty();
    }

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

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

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

    /** 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 'orderRef' field has been set, however the value could be null */
    public boolean hasOrderRef() {
        return genClient.cacheHasKey(CacheKey.orderRef);
    }

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

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

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

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

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

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

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

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

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

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

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

    /**
     * Sets the field 'orderRef'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setOrderRef(com.clover.sdk.v3.base.Reference orderRef) {
        return genClient.setRecord(orderRef, CacheKey.orderRef);
    }

    /**
     * Sets the field 'device'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setDevice(com.clover.sdk.v3.base.Reference device) {
        return genClient.setRecord(device, CacheKey.device);
    }

    /**
     * Sets the field 'tender'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setTender(com.clover.sdk.v3.base.Tender tender) {
        return genClient.setRecord(tender, CacheKey.tender);
    }

    /**
     * Sets the field 'employee'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setEmployee(com.clover.sdk.v3.base.Reference employee) {
        return genClient.setRecord(employee, CacheKey.employee);
    }

    /**
     * Sets the field 'customers'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setCustomers(com.clover.sdk.v3.customers.Customer customers) {
        return genClient.setRecord(customers, CacheKey.customers);
    }

    /**
     * Sets the field 'amount'.
     */
    public Credit setAmount(java.lang.Long amount) {
        return genClient.setOther(amount, CacheKey.amount);
    }

    /**
     * Sets the field 'taxAmount'.
     */
    public Credit setTaxAmount(java.lang.Long taxAmount) {
        return genClient.setOther(taxAmount, CacheKey.taxAmount);
    }

    /**
     * Sets the field 'taxRates'.
     *
     * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will.
     */
    public Credit setTaxRates(java.util.List<com.clover.sdk.v3.payments.TaxableAmountRate> taxRates) {
        return genClient.setArrayRecord(taxRates, CacheKey.taxRates);
    }

    /**
     * Sets the field 'createdTime'.
     */
    public Credit setCreatedTime(java.lang.Long createdTime) {
        return genClient.setOther(createdTime, CacheKey.createdTime);
    }

    /**
     * Sets the field 'clientCreatedTime'.
     */
    public Credit setClientCreatedTime(java.lang.Long clientCreatedTime) {
        return genClient.setOther(clientCreatedTime, CacheKey.clientCreatedTime);
    }

    /**
     * Sets the field 'cardTransaction'.
     *
     * The parameter is not copied so changes to it will be reflected in this instance and vice-versa.
     */
    public Credit setCardTransaction(com.clover.sdk.v3.payments.CardTransaction cardTransaction) {
        return genClient.setRecord(cardTransaction, CacheKey.cardTransaction);
    }

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * 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 Credit copyChanges() {
        Credit copy = new Credit();
        copy.mergeChanges(this);
        copy.resetChangeLog();
        return copy;
    }

    /**
     * Copy all the changed fields from the given source to this instance.
     */
    public void mergeChanges(Credit src) {
        if (src.genClient.getChangeLog() != null) {
            genClient.mergeChanges(new Credit(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<Credit> CREATOR = new android.os.Parcelable.Creator<Credit>() {
        @Override
        public Credit createFromParcel(android.os.Parcel in) {
            Credit instance = new Credit(
                    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 Credit[] newArray(int size) {
            return new Credit[size];
        }
    };

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

    public interface Constraints {

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

        public static final boolean ORDERREF_IS_REQUIRED = false;

        public static final boolean DEVICE_IS_REQUIRED = false;

        public static final boolean TENDER_IS_REQUIRED = false;

        public static final boolean EMPLOYEE_IS_REQUIRED = false;

        public static final boolean CUSTOMERS_IS_REQUIRED = false;

        public static final boolean AMOUNT_IS_REQUIRED = false;

        public static final boolean TAXAMOUNT_IS_REQUIRED = false;

        public static final boolean TAXRATES_IS_REQUIRED = false;

        public static final boolean CREATEDTIME_IS_REQUIRED = false;

        public static final boolean CLIENTCREATEDTIME_IS_REQUIRED = false;

        public static final boolean CARDTRANSACTION_IS_REQUIRED = false;

    }

}