Package com.clover.sdk
Class GenericClient<D>
- java.lang.Object
-
- com.clover.sdk.GenericClient<D>
-
public final class GenericClient<D> extends Object
For Clover internal use only.There are two copies of this file, one in clover-android-sdk and one in schema-tool, please keep them in sync.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GenericClient.StrictValidationFailedCallback
-
Constructor Summary
Constructors Constructor Description GenericClient(GenericClient src)
Constructs a new instance that is a deep copy of the source instance.GenericClient(D callingObject)
Constructs a new GenericClient with the instance of the declaring class saved.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> T
cacheGet(ExtractableEnum cacheKey)
Replacement for the various cache methods.boolean
cacheHasKey(ExtractableEnum cacheKey)
void
cacheMarkDirty(ExtractableEnum cacheKey)
void
cacheRemoveValue(ExtractableEnum cacheKey)
boolean
cacheValueIsNotNull(ExtractableEnum cacheKey)
void
clear(ExtractableEnum key)
Clears the 'field' field, the 'has' method for this field will now return falseboolean
containsChanges()
Returns true if this instance has any changes.<T extends Enum<T>>
TextractEnum(String name, Class<T> clazz)
Generic method that replaces the "extract" methods which dealt with an Enum.<T extends Enum<T>>
List<T>extractListEnum(String name, Class<T> clazz)
Generic method that returns a list of T items.<T> List<T>
extractListOther(String name, Class<T> clazz)
Generic method that returns a list of T items.<T> List<T>
extractListRecord(String name, JSONifiable.Creator<T> JSON_CREATOR)
Generic method that returns a list of T items.Map
extractMap(String name)
Generic method that replaces the "extract" methods which dealt with a Map.<T> T
extractOther(String name, Class<T> clazz)
Generic method that replaces the "extract" methods which dealt with anything else (not a Record, Enum, or Map).<T> T
extractRecord(String name, JSONifiable.Creator<T> JSON_CREATOR)
Generic method that replaces the "extract" methods which dealt with a Record.Bundle
getBundle()
Gets a Bundle which can be used to get and set data attached to this instance.Bundle
getChangeLog()
Get access to changeLogJSONObject
getJsonObject()
JSONObject
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.void
initJsonObject(String json)
void
logChange(String field)
Update log when necessary.void
mergeChanges(JSONObject srcObj, GenericClient srcGC)
Generic method that replaces the "mergeChanges" method in all the classes.void
resetChangeLog()
Reset the log of changes made to this instance, calling copyChanges() after this would return an empty instance.<T> D
setArrayOther(List<T> list, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Arrays that hold non-Records.<T extends JSONifiable>
DsetArrayRecord(List<T> list, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Arrays that hold Records.void
setBundle(Bundle newBundle)
Change bundle to a new bundle sent in.void
setChangeLog(Bundle newChangeLog)
Change log to a new log sent in.void
setJsonObject(JSONObject newJSONObject)
<T> D
setOther(T item, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with anything else (not an Array or Record).<T extends JSONifiable>
DsetRecord(T item, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Records.static void
setStrictValidationFailedCallback(GenericClient.StrictValidationFailedCallback callback)
For internal use only.String
toString()
void
unlogChange(String field)
Remove from log when necessary.void
validateCloverId(ExtractableEnum cacheKey, String id)
Check if the given id is a valid Clover ID, if not throw IllegalArgumentException.void
validateLength(ExtractableEnum cacheKey, String value, long maxLength)
void
validateLength(String value, long maxLength)
Deprecated.UsevalidateLength(ExtractableEnum, String, long)
instead.void
validateMax(ExtractableEnum cacheKey, Double value, double max)
void
validateMax(ExtractableEnum cacheKey, Float value, double max)
void
validateMax(ExtractableEnum cacheKey, Integer value, long max)
void
validateMax(ExtractableEnum cacheKey, Long value, long max)
void
validateMin(ExtractableEnum cacheKey, Double value, double min)
void
validateMin(ExtractableEnum cacheKey, Float value, double min)
void
validateMin(ExtractableEnum cacheKey, Integer value, long min)
void
validateMin(ExtractableEnum cacheKey, Long value, long min)
void
validateMinMax(ExtractableEnum cacheKey, Double value, double min, double max)
void
validateMinMax(ExtractableEnum cacheKey, Float value, double min, double max)
void
validateMinMax(ExtractableEnum cacheKey, Integer value, long min, long max)
void
validateMinMax(ExtractableEnum cacheKey, Long value, long min, long max)
<T> void
validateNotNull(ExtractableEnum cacheKey, T value)
<T> void
validateNull(T field, String name)
Deprecated.UsevalidateNotNull(ExtractableEnum, Object)
insteadvoid
validateReferences(ExtractionStrategyEnum cacheKey)
void
writeToParcel(Parcel dest, int flags)
Method that replaces the "writeToParcel" methods.
-
-
-
Constructor Detail
-
GenericClient
public GenericClient(D callingObject)
Constructs a new GenericClient with the instance of the declaring class saved.
-
GenericClient
public GenericClient(GenericClient src)
Constructs a new instance that is a deep copy of the source instance. It does not copy the bundle or changelog.
-
-
Method Detail
-
cacheGet
public <T> T cacheGet(ExtractableEnum cacheKey)
Replacement for the various cache methods.
-
cacheValueIsNotNull
public boolean cacheValueIsNotNull(ExtractableEnum cacheKey)
-
cacheHasKey
public boolean cacheHasKey(ExtractableEnum cacheKey)
-
cacheRemoveValue
public void cacheRemoveValue(ExtractableEnum cacheKey)
-
cacheMarkDirty
public void cacheMarkDirty(ExtractableEnum cacheKey)
-
validateNull
@Deprecated public <T> void validateNull(T field, String name)
Deprecated.UsevalidateNotNull(ExtractableEnum, Object)
insteadDeprecated but kept since we do not always regenerate all objects. This method is a misnomer, it should have been validateNotNull since it validates that the field is not null and fails if it is.
-
validateNotNull
public <T> void validateNotNull(ExtractableEnum cacheKey, T value)
-
validateLength
@Deprecated public void validateLength(String value, long maxLength)
Deprecated.UsevalidateLength(ExtractableEnum, String, long)
instead.Deprecated but kept since we do not always regenerate all objects.
-
validateLength
public void validateLength(ExtractableEnum cacheKey, String value, long maxLength)
-
validateMin
public void validateMin(ExtractableEnum cacheKey, Integer value, long min)
-
validateMax
public void validateMax(ExtractableEnum cacheKey, Integer value, long max)
-
validateMinMax
public void validateMinMax(ExtractableEnum cacheKey, Integer value, long min, long max)
-
validateMin
public void validateMin(ExtractableEnum cacheKey, Long value, long min)
-
validateMax
public void validateMax(ExtractableEnum cacheKey, Long value, long max)
-
validateMinMax
public void validateMinMax(ExtractableEnum cacheKey, Long value, long min, long max)
-
validateMin
public void validateMin(ExtractableEnum cacheKey, Float value, double min)
-
validateMax
public void validateMax(ExtractableEnum cacheKey, Float value, double max)
-
validateMinMax
public void validateMinMax(ExtractableEnum cacheKey, Float value, double min, double max)
-
validateMin
public void validateMin(ExtractableEnum cacheKey, Double value, double min)
-
validateMax
public void validateMax(ExtractableEnum cacheKey, Double value, double max)
-
validateMinMax
public void validateMinMax(ExtractableEnum cacheKey, Double value, double min, double max)
-
validateCloverId
public void validateCloverId(ExtractableEnum cacheKey, String id)
Check if the given id is a valid Clover ID, if not throw IllegalArgumentException.
-
validateReferences
public void validateReferences(ExtractionStrategyEnum cacheKey)
-
setStrictValidationFailedCallback
public static void setStrictValidationFailedCallback(GenericClient.StrictValidationFailedCallback callback)
For internal use only.
-
getJsonObject
public JSONObject getJsonObject()
-
setJsonObject
public void setJsonObject(JSONObject newJSONObject)
-
initJsonObject
public void initJsonObject(String json)
-
getJSONObject
public JSONObject 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.
-
logChange
public void logChange(String field)
Update log when necessary.
-
unlogChange
public void unlogChange(String field)
Remove from log when necessary.
-
containsChanges
public boolean containsChanges()
Returns true if this instance has any changes.
-
resetChangeLog
public void resetChangeLog()
Reset the log of changes made to this instance, calling copyChanges() after this would return an empty instance.
-
setChangeLog
public void setChangeLog(Bundle newChangeLog)
Change log to a new log sent in.
-
clear
public void clear(ExtractableEnum key)
Clears the 'field' field, the 'has' method for this field will now return false
-
getBundle
public Bundle getBundle()
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.
-
setBundle
public void setBundle(Bundle newBundle)
Change bundle to a new bundle sent in.
-
getChangeLog
public Bundle getChangeLog()
Get access to changeLog
-
extractListRecord
public <T> List<T> extractListRecord(String name, JSONifiable.Creator<T> JSON_CREATOR)
Generic method that returns a list of T items. Replacement for the "extract" methods which dealt with a list of Records.
-
extractListEnum
public <T extends Enum<T>> List<T> extractListEnum(String name, Class<T> clazz)
Generic method that returns a list of T items. Replacement for the "extract" methods which dealt with a list of Enums.
-
extractListOther
public <T> List<T> extractListOther(String name, Class<T> clazz)
Generic method that returns a list of T items. Replacement for the "extract" methods which dealt with a list of other items (neither Records nor Enums).
-
extractRecord
public <T> T extractRecord(String name, JSONifiable.Creator<T> JSON_CREATOR)
Generic method that replaces the "extract" methods which dealt with a Record.
-
extractEnum
public <T extends Enum<T>> T extractEnum(String name, Class<T> clazz)
Generic method that replaces the "extract" methods which dealt with an Enum.
-
extractMap
public Map extractMap(String name)
Generic method that replaces the "extract" methods which dealt with a Map.
-
extractOther
public <T> T extractOther(String name, Class<T> clazz)
Generic method that replaces the "extract" methods which dealt with anything else (not a Record, Enum, or Map).
-
setArrayRecord
public <T extends JSONifiable> D setArrayRecord(List<T> list, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Arrays that hold Records.
-
setArrayOther
public <T> D setArrayOther(List<T> list, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Arrays that hold non-Records.
-
setRecord
public <T extends JSONifiable> D setRecord(T item, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with Records.
-
setOther
public <T> D setOther(T item, ExtractableEnum key)
Generic method that replaces the "set" methods which dealt with anything else (not an Array or Record).
-
mergeChanges
public void mergeChanges(JSONObject srcObj, GenericClient srcGC)
Generic method that replaces the "mergeChanges" method in all the classes.
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
Method that replaces the "writeToParcel" methods. "flags" seems to be unused, but was also passed in the original classes.
-
-