com.clover.sdk.v3.inventory.ItemModifierGroup.java Source code

Java tutorial

Introduction

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

import com.clover.sdk.GenericClient;

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

    public com.clover.sdk.v3.inventory.Item getItem() {
        return genClient.cacheGet(CacheKey.item);
    }

    public com.clover.sdk.v3.inventory.ModifierGroup getModifierGroup() {
        return genClient.cacheGet(CacheKey.modifierGroup);
    }

    private enum CacheKey implements com.clover.sdk.ValueExtractorEnum<ItemModifierGroup> {
        item {
            @Override
            public Object extractValue(ItemModifierGroup instance) {
                return instance.genClient.extractRecord("item", com.clover.sdk.v3.inventory.Item.JSON_CREATOR);
            }
        },
        modifierGroup {
            @Override
            public Object extractValue(ItemModifierGroup instance) {
                return instance.genClient.extractRecord("modifierGroup",
                        com.clover.sdk.v3.inventory.ModifierGroup.JSON_CREATOR);
            }
        },;
    }

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

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

    /**
     * Constructs a new instance from the given JSON String.
     */
    public ItemModifierGroup(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 ItemModifierGroup(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 ItemModifierGroup(ItemModifierGroup 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.validateNull(getItem(), "item");

        genClient.validateNull(getModifierGroup(), "modifierGroup");
    }

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

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

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

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

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

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

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

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

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

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

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

    public interface Constraints {

        public static final boolean ITEM_IS_REQUIRED = true;

        public static final boolean MODIFIERGROUP_IS_REQUIRED = true;

    }

}