Java tutorial
/** * 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.hours; import com.clover.sdk.GenericClient; @SuppressWarnings("all") public final class HoursSet 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); } /** * Friendly name to describe the hours */ public java.lang.String getName() { return genClient.cacheGet(CacheKey.name); } public com.clover.sdk.v3.hours.Reference getReference() { return genClient.cacheGet(CacheKey.reference); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getSunday() { return genClient.cacheGet(CacheKey.sunday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getMonday() { return genClient.cacheGet(CacheKey.monday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getTuesday() { return genClient.cacheGet(CacheKey.tuesday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getWednesday() { return genClient.cacheGet(CacheKey.wednesday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getThursday() { return genClient.cacheGet(CacheKey.thursday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getFriday() { return genClient.cacheGet(CacheKey.friday); } public java.util.List<com.clover.sdk.v3.hours.HourRange> getSaturday() { return genClient.cacheGet(CacheKey.saturday); } private enum CacheKey implements com.clover.sdk.ValueExtractorEnum<HoursSet> { id { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractOther("id", java.lang.String.class); } }, name { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractOther("name", java.lang.String.class); } }, reference { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractRecord("reference", com.clover.sdk.v3.hours.Reference.JSON_CREATOR); } }, sunday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("sunday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, monday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("monday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, tuesday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("tuesday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, wednesday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("wednesday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, thursday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("thursday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, friday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("friday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } }, saturday { @Override public Object extractValue(HoursSet instance) { return instance.genClient.extractListRecord("saturday", com.clover.sdk.v3.hours.HourRange.JSON_CREATOR); } },; } private GenericClient<HoursSet> genClient = new GenericClient<HoursSet>(this); /** * Constructs a new empty instance. */ public HoursSet() { } /** * Constructs a new instance from the given JSON String. */ public HoursSet(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 HoursSet(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 HoursSet(HoursSet 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(getName(), 20); } /** Checks whether the 'id' field is set and is not null */ public boolean isNotNullId() { return genClient.cacheValueIsNotNull(CacheKey.id); } /** Checks whether the 'name' field is set and is not null */ public boolean isNotNullName() { return genClient.cacheValueIsNotNull(CacheKey.name); } /** Checks whether the 'reference' field is set and is not null */ public boolean isNotNullReference() { return genClient.cacheValueIsNotNull(CacheKey.reference); } /** Checks whether the 'sunday' field is set and is not null */ public boolean isNotNullSunday() { return genClient.cacheValueIsNotNull(CacheKey.sunday); } /** Checks whether the 'sunday' field is set and is not null and is not empty */ public boolean isNotEmptySunday() { return isNotNullSunday() && !getSunday().isEmpty(); } /** Checks whether the 'monday' field is set and is not null */ public boolean isNotNullMonday() { return genClient.cacheValueIsNotNull(CacheKey.monday); } /** Checks whether the 'monday' field is set and is not null and is not empty */ public boolean isNotEmptyMonday() { return isNotNullMonday() && !getMonday().isEmpty(); } /** Checks whether the 'tuesday' field is set and is not null */ public boolean isNotNullTuesday() { return genClient.cacheValueIsNotNull(CacheKey.tuesday); } /** Checks whether the 'tuesday' field is set and is not null and is not empty */ public boolean isNotEmptyTuesday() { return isNotNullTuesday() && !getTuesday().isEmpty(); } /** Checks whether the 'wednesday' field is set and is not null */ public boolean isNotNullWednesday() { return genClient.cacheValueIsNotNull(CacheKey.wednesday); } /** Checks whether the 'wednesday' field is set and is not null and is not empty */ public boolean isNotEmptyWednesday() { return isNotNullWednesday() && !getWednesday().isEmpty(); } /** Checks whether the 'thursday' field is set and is not null */ public boolean isNotNullThursday() { return genClient.cacheValueIsNotNull(CacheKey.thursday); } /** Checks whether the 'thursday' field is set and is not null and is not empty */ public boolean isNotEmptyThursday() { return isNotNullThursday() && !getThursday().isEmpty(); } /** Checks whether the 'friday' field is set and is not null */ public boolean isNotNullFriday() { return genClient.cacheValueIsNotNull(CacheKey.friday); } /** Checks whether the 'friday' field is set and is not null and is not empty */ public boolean isNotEmptyFriday() { return isNotNullFriday() && !getFriday().isEmpty(); } /** Checks whether the 'saturday' field is set and is not null */ public boolean isNotNullSaturday() { return genClient.cacheValueIsNotNull(CacheKey.saturday); } /** Checks whether the 'saturday' field is set and is not null and is not empty */ public boolean isNotEmptySaturday() { return isNotNullSaturday() && !getSaturday().isEmpty(); } /** 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 'name' field has been set, however the value could be null */ public boolean hasName() { return genClient.cacheHasKey(CacheKey.name); } /** Checks whether the 'reference' field has been set, however the value could be null */ public boolean hasReference() { return genClient.cacheHasKey(CacheKey.reference); } /** Checks whether the 'sunday' field has been set, however the value could be null */ public boolean hasSunday() { return genClient.cacheHasKey(CacheKey.sunday); } /** Checks whether the 'monday' field has been set, however the value could be null */ public boolean hasMonday() { return genClient.cacheHasKey(CacheKey.monday); } /** Checks whether the 'tuesday' field has been set, however the value could be null */ public boolean hasTuesday() { return genClient.cacheHasKey(CacheKey.tuesday); } /** Checks whether the 'wednesday' field has been set, however the value could be null */ public boolean hasWednesday() { return genClient.cacheHasKey(CacheKey.wednesday); } /** Checks whether the 'thursday' field has been set, however the value could be null */ public boolean hasThursday() { return genClient.cacheHasKey(CacheKey.thursday); } /** Checks whether the 'friday' field has been set, however the value could be null */ public boolean hasFriday() { return genClient.cacheHasKey(CacheKey.friday); } /** Checks whether the 'saturday' field has been set, however the value could be null */ public boolean hasSaturday() { return genClient.cacheHasKey(CacheKey.saturday); } /** * Sets the field 'id'. */ public HoursSet setId(java.lang.String id) { return genClient.setOther(id, CacheKey.id); } /** * Sets the field 'name'. */ public HoursSet setName(java.lang.String name) { return genClient.setOther(name, CacheKey.name); } /** * Sets the field 'reference'. * * The parameter is not copied so changes to it will be reflected in this instance and vice-versa. */ public HoursSet setReference(com.clover.sdk.v3.hours.Reference reference) { return genClient.setRecord(reference, CacheKey.reference); } /** * Sets the field 'sunday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setSunday(java.util.List<com.clover.sdk.v3.hours.HourRange> sunday) { return genClient.setArrayRecord(sunday, CacheKey.sunday); } /** * Sets the field 'monday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setMonday(java.util.List<com.clover.sdk.v3.hours.HourRange> monday) { return genClient.setArrayRecord(monday, CacheKey.monday); } /** * Sets the field 'tuesday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setTuesday(java.util.List<com.clover.sdk.v3.hours.HourRange> tuesday) { return genClient.setArrayRecord(tuesday, CacheKey.tuesday); } /** * Sets the field 'wednesday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setWednesday(java.util.List<com.clover.sdk.v3.hours.HourRange> wednesday) { return genClient.setArrayRecord(wednesday, CacheKey.wednesday); } /** * Sets the field 'thursday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setThursday(java.util.List<com.clover.sdk.v3.hours.HourRange> thursday) { return genClient.setArrayRecord(thursday, CacheKey.thursday); } /** * Sets the field 'friday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setFriday(java.util.List<com.clover.sdk.v3.hours.HourRange> friday) { return genClient.setArrayRecord(friday, CacheKey.friday); } /** * Sets the field 'saturday'. * * Nulls in the given List are skipped. List parameter is copied, so it will not reflect any changes, but objects inside it will. */ public HoursSet setSaturday(java.util.List<com.clover.sdk.v3.hours.HourRange> saturday) { return genClient.setArrayRecord(saturday, CacheKey.saturday); } /** Clears the 'id' field, the 'has' method for this field will now return false */ public void clearId() { genClient.clear(CacheKey.id); } /** Clears the 'name' field, the 'has' method for this field will now return false */ public void clearName() { genClient.clear(CacheKey.name); } /** Clears the 'reference' field, the 'has' method for this field will now return false */ public void clearReference() { genClient.clear(CacheKey.reference); } /** Clears the 'sunday' field, the 'has' method for this field will now return false */ public void clearSunday() { genClient.clear(CacheKey.sunday); } /** Clears the 'monday' field, the 'has' method for this field will now return false */ public void clearMonday() { genClient.clear(CacheKey.monday); } /** Clears the 'tuesday' field, the 'has' method for this field will now return false */ public void clearTuesday() { genClient.clear(CacheKey.tuesday); } /** Clears the 'wednesday' field, the 'has' method for this field will now return false */ public void clearWednesday() { genClient.clear(CacheKey.wednesday); } /** Clears the 'thursday' field, the 'has' method for this field will now return false */ public void clearThursday() { genClient.clear(CacheKey.thursday); } /** Clears the 'friday' field, the 'has' method for this field will now return false */ public void clearFriday() { genClient.clear(CacheKey.friday); } /** Clears the 'saturday' field, the 'has' method for this field will now return false */ public void clearSaturday() { genClient.clear(CacheKey.saturday); } /** * 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 HoursSet copyChanges() { HoursSet copy = new HoursSet(); copy.mergeChanges(this); copy.resetChangeLog(); return copy; } /** * Copy all the changed fields from the given source to this instance. */ public void mergeChanges(HoursSet src) { if (src.genClient.getChangeLog() != null) { genClient.mergeChanges(new HoursSet(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<HoursSet> CREATOR = new android.os.Parcelable.Creator<HoursSet>() { @Override public HoursSet createFromParcel(android.os.Parcel in) { HoursSet instance = new HoursSet( 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 HoursSet[] newArray(int size) { return new HoursSet[size]; } }; public static final com.clover.sdk.JSONifiable.Creator<HoursSet> JSON_CREATOR = new com.clover.sdk.JSONifiable.Creator<HoursSet>() { @Override public HoursSet create(org.json.JSONObject jsonObject) { return new HoursSet(jsonObject); } }; public interface Constraints { public static final boolean ID_IS_REQUIRED = false; public static final long ID_MAX_LEN = 13; public static final boolean NAME_IS_REQUIRED = false; public static final long NAME_MAX_LEN = 20; public static final boolean REFERENCE_IS_REQUIRED = false; public static final boolean SUNDAY_IS_REQUIRED = false; public static final boolean MONDAY_IS_REQUIRED = false; public static final boolean TUESDAY_IS_REQUIRED = false; public static final boolean WEDNESDAY_IS_REQUIRED = false; public static final boolean THURSDAY_IS_REQUIRED = false; public static final boolean FRIDAY_IS_REQUIRED = false; public static final boolean SATURDAY_IS_REQUIRED = false; } }