Package com.clover.sdk.v3.inventory
Class Discount
- java.lang.Object
-
- com.clover.sdk.GenericParcelable
-
- com.clover.sdk.v3.inventory.Discount
-
- All Implemented Interfaces:
Parcelable
,JSONifiable
,Validator
public class Discount extends GenericParcelable implements Validator, JSONifiable
- See Also:
IInventoryService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Discount.Constraints
-
Nested classes/interfaces inherited from interface com.clover.sdk.JSONifiable
JSONifiable.Creator<T>
-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static Parcelable.Creator<Discount>
CREATOR
static JSONifiable.Creator<Discount>
JSON_CREATOR
-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Modifier Constructor Description Discount()
Constructs a new empty instance.protected
Discount(boolean noInit)
Constructs a new empty instance.Discount(Discount src)
Constructs a new instance that is a deep copy of the source instance.Discount(String json)
Constructs a new instance from the given JSON String.Discount(JSONObject jsonObject)
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAmount()
Clears the 'amount' field, the 'has' method for this field will now return falsevoid
clearId()
Clears the 'id' field, the 'has' method for this field will now return falsevoid
clearName()
Clears the 'name' field, the 'has' method for this field will now return falsevoid
clearPercentage()
Clears the 'percentage' field, the 'has' method for this field will now return falseboolean
containsChanges()
Returns true if this instance has any changes.Discount
copyChanges()
Create a copy of this instance that contains only fields that were set after the constructor was called.Long
getAmount()
Discount amount in fraction of currency unit (e.g.protected GenericClient
getGenericClient()
String
getId()
Unique identifierJSONObject
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.String
getName()
Name of the discountLong
getPercentage()
Discount amount in percentboolean
hasAmount()
Checks whether the 'amount' field has been set, however the value could be nullboolean
hasId()
Checks whether the 'id' field has been set, however the value could be nullboolean
hasName()
Checks whether the 'name' field has been set, however the value could be nullboolean
hasPercentage()
Checks whether the 'percentage' field has been set, however the value could be nullboolean
isNotNullAmount()
Checks whether the 'amount' field is set and is not nullboolean
isNotNullId()
Checks whether the 'id' field is set and is not nullboolean
isNotNullName()
Checks whether the 'name' field is set and is not nullboolean
isNotNullPercentage()
Checks whether the 'percentage' field is set and is not nullvoid
mergeChanges(Discount src)
Copy all the changed fields from the given source to this instance.void
resetChangeLog()
Reset the log of changes made to this instance, calling copyChanges() after this would return an empty instance.Discount
setAmount(Long amount)
Sets the field 'amount'.Discount
setId(String id)
Sets the field 'id'.Discount
setName(String name)
Sets the field 'name'.Discount
setPercentage(Long percentage)
Sets the field 'percentage'.void
validate()
-
Methods inherited from class com.clover.sdk.GenericParcelable
describeContents, getBundle, toString, writeToParcel
-
-
-
-
Field Detail
-
CREATOR
public static final Parcelable.Creator<Discount> CREATOR
-
JSON_CREATOR
public static final JSONifiable.Creator<Discount> JSON_CREATOR
-
-
Constructor Detail
-
Discount
public Discount()
Constructs a new empty instance.
-
Discount
protected Discount(boolean noInit)
Constructs a new empty instance.
-
Discount
public Discount(String json) throws IllegalArgumentException
Constructs a new instance from the given JSON String.- Throws:
IllegalArgumentException
-
Discount
public Discount(JSONObject jsonObject)
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.
-
Discount
public Discount(Discount src)
Constructs a new instance that is a deep copy of the source instance. It does not copy the bundle or changelog.
-
-
Method Detail
-
getId
public String getId()
Unique identifier
-
getName
public String getName()
Name of the discount
-
getAmount
public Long getAmount()
Discount amount in fraction of currency unit (e.g. cents) based on currency fraction digits supported
-
getPercentage
public Long getPercentage()
Discount amount in percent
-
getGenericClient
protected GenericClient getGenericClient()
- Specified by:
getGenericClient
in classGenericParcelable
-
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.- Specified by:
getJSONObject
in interfaceJSONifiable
-
isNotNullId
public boolean isNotNullId()
Checks whether the 'id' field is set and is not null
-
isNotNullName
public boolean isNotNullName()
Checks whether the 'name' field is set and is not null
-
isNotNullAmount
public boolean isNotNullAmount()
Checks whether the 'amount' field is set and is not null
-
isNotNullPercentage
public boolean isNotNullPercentage()
Checks whether the 'percentage' field is set and is not null
-
hasId
public boolean hasId()
Checks whether the 'id' field has been set, however the value could be null
-
hasName
public boolean hasName()
Checks whether the 'name' field has been set, however the value could be null
-
hasAmount
public boolean hasAmount()
Checks whether the 'amount' field has been set, however the value could be null
-
hasPercentage
public boolean hasPercentage()
Checks whether the 'percentage' field has been set, however the value could be null
-
clearId
public void clearId()
Clears the 'id' field, the 'has' method for this field will now return false
-
clearName
public void clearName()
Clears the 'name' field, the 'has' method for this field will now return false
-
clearAmount
public void clearAmount()
Clears the 'amount' field, the 'has' method for this field will now return false
-
clearPercentage
public void clearPercentage()
Clears the 'percentage' field, the 'has' method for this field will now return false
-
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.
-
copyChanges
public Discount copyChanges()
Create a copy of this instance that contains only fields that were set after the constructor was called.
-
mergeChanges
public void mergeChanges(Discount src)
Copy all the changed fields from the given source to this instance.
-
-