public abstract class BaseFssApiResource
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.nio.charset.Charset |
UTF_8
The UTF-8 Charset
|
| Constructor and Description |
|---|
BaseFssApiResource() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
badValue(java.lang.String fieldName,
java.lang.String parentFieldName)
Calls
badValue with a null reason. |
protected void |
badValue(java.lang.String fieldName,
java.lang.String parentFieldName,
java.lang.String reason)
Throws an AwJsonException with a message that the fieldName is not valid.
|
static <T extends BaseFssApiResource> |
fromJson(FssApiVersion version,
java.io.Reader reader,
java.lang.Class<T> type)
Reads the JSON representation of an object from the specified reader and converts it to an
object of the specified type.
|
java.lang.String |
toJson()
Returns the JSON representation of this object.
|
static java.lang.String |
toJson(java.lang.Object o)
Returns the JSON representation of the specified object.
|
java.lang.String |
toString()
The JSON representation of the specified object.
|
void |
validate()
Validates this object.
|
protected abstract void |
validate(java.lang.String fieldName,
BaseFssApiResource parent)
Validates this object.
|
protected void |
validateFieldInRange(java.lang.String fieldName,
java.lang.Integer fieldValue,
int min,
int max,
java.lang.String parentFieldName)
Validates that fieldValue is in the range min to max.
|
protected void |
validateFieldInRange(java.lang.String fieldName,
java.lang.Long fieldValue,
long min,
long max,
java.lang.String parentFieldName)
Validates that fieldValue is in the range min to max.
|
protected void |
validateFieldIsNull(java.lang.String fieldName,
java.lang.Object fieldValue,
java.lang.String parentFieldName)
Validates that fieldValue is null.
|
protected void |
validateFieldNotNull(java.lang.String fieldName,
java.lang.Object fieldValue,
java.lang.String parentFieldName)
Validates that fieldValue is not null.
|
protected void |
validateLocale(java.lang.String fieldName,
java.lang.String fieldValue,
java.lang.String parentFieldName)
Validates that the provided locale is supported
|
protected void |
validateOptionalField(java.lang.String fieldName,
BaseFssApiResource fieldValue)
Validates an optional field of your choice.
|
protected <T> void |
validateOptionalFieldList(java.lang.String fieldName,
java.util.List<T> fieldValues,
java.lang.String parentFieldName)
Validates an optional list.
|
protected void |
validateRequiredField(java.lang.String fieldName,
BaseFssApiResource fieldValue,
java.lang.String parentFieldName)
Validates that fieldValue is not null and is valid.
|
protected <T> void |
validateRequiredFieldList(java.lang.String fieldName,
java.util.List<T> fieldValues,
java.lang.String parentFieldName)
Validates that the fieldValues are not null and that all objects contained within it are not
null and are valid.
|
static void |
writeToOutputStream(java.lang.Object o,
java.io.OutputStream outputStream)
Writes the JSON representation of the specified Object to the outputStream.
|
public static void writeToOutputStream(java.lang.Object o,
java.io.OutputStream outputStream)
throws java.io.IOException
o - the object whose JSON representation is to be written to the OutputStreamoutputStream - the OutputStream where the JSON representation of the specified Object is writtenjava.io.IOExceptionpublic static java.lang.String toJson(java.lang.Object o)
public java.lang.String toJson()
public static <T extends BaseFssApiResource> T fromJson(FssApiVersion version, java.io.Reader reader, java.lang.Class<T> type) throws AwJsonException
T - the object to be returnedversion - FSS API version of the object to be readreader - contains the JSON string that will be readtype - the Class or base class of the object that will be returnedAwJsonExceptionpublic void validate()
throws AwJsonException
AwJsonException - if any validation errors occurprotected abstract void validate(java.lang.String fieldName,
BaseFssApiResource parent)
throws AwJsonException
validateRequiredField(String, BaseFssApiResource, String) for foo, and
validateOptionalField(String, BaseFssApiResource) for bar.fieldName - name of this object in the parent (containing) object. If this object is a
top-level object (not contained within another object), then enter null for this
parameterparent - parent (containing) object that contains the object specified in the fieldName
parameter. If this object is a top-level object (not contained within another
object), then enter null for this parameterAwJsonException - if any validation errors occurprotected void validateRequiredField(java.lang.String fieldName,
BaseFssApiResource fieldValue,
java.lang.String parentFieldName)
throws AwJsonException
validate(String, BaseFssApiResource) on fieldValue.fieldName - name of fieldValue in the parent (containing) objectfieldValue - object to be validatedparentFieldName - name of the parent field that contains fieldValueAwJsonException - if any validation errors occurprotected void validateOptionalField(java.lang.String fieldName,
BaseFssApiResource fieldValue)
throws AwJsonException
validate is called on fieldValue.fieldName - name of fieldValue in the parent (containing) objectfieldValue - object to be validated if it is not nullAwJsonExceptionprotected <T> void validateRequiredFieldList(java.lang.String fieldName,
java.util.List<T> fieldValues,
java.lang.String parentFieldName)
throws AwJsonException
Validate is called on all
objects within fieldValues.fieldName - name of fieldValue in the parent (containing) objectfieldValues - list of objects to be validatedparentFieldName - name of the parent field that contains fieldValuesAwJsonExceptionprotected <T> void validateOptionalFieldList(java.lang.String fieldName,
java.util.List<T> fieldValues,
java.lang.String parentFieldName)
throws AwJsonException
validate(String, BaseFssApiResource) is called on all objects specified in
fieldValues.fieldName - name of fieldValues in the parent (containing) objectfieldValues - list of objects to be validatedparentFieldName - name of the parent field that contains fieldValuesAwJsonExceptionprotected void validateFieldNotNull(java.lang.String fieldName,
java.lang.Object fieldValue,
java.lang.String parentFieldName)
throws AwJsonException
fieldName - name of fieldValue in the parent (containing) objectfieldValue - object to be validated. This cannot be nullparentFieldName - name of the parent field that contains fieldValueAwJsonException - if fieldValue is nullprotected void validateFieldInRange(java.lang.String fieldName,
java.lang.Long fieldValue,
long min,
long max,
java.lang.String parentFieldName)
throws AwJsonException
fieldName - the name of fieldValue in the parent (containing) objectfieldValue - the field that must fall in the rangemin - the minimum value of the fieldmax - the maximum value of the fieldAwJsonExceptionprotected void validateFieldInRange(java.lang.String fieldName,
java.lang.Integer fieldValue,
int min,
int max,
java.lang.String parentFieldName)
throws AwJsonException
fieldName - the name of fieldValue in the parent (containing) objectfieldValue - the field that must fall in the rangemin - the minimum value of the fieldmax - the maximum value of the fieldAwJsonExceptionprotected void validateFieldIsNull(java.lang.String fieldName,
java.lang.Object fieldValue,
java.lang.String parentFieldName)
throws AwJsonException
fieldName - name of fieldValue in the parent (containing) objectfieldValue - an object. This parameter cannot be nullparentFieldName - name of the parent field that contains fieldValueAwJsonException - if fieldValue is nullprotected void validateLocale(java.lang.String fieldName,
java.lang.String fieldValue,
java.lang.String parentFieldName)
throws AwJsonException
fieldName - name of fieldValue in the parent (containing) objectfieldValue - string representing locale to be validatedparentFieldName - name of the parent field that contains fieldValueAwJsonExceptionprotected void badValue(java.lang.String fieldName,
java.lang.String parentFieldName)
throws AwJsonException
badValue with a null reason.AwJsonException - always thrownprotected void badValue(java.lang.String fieldName,
java.lang.String parentFieldName,
java.lang.String reason)
throws AwJsonException
fieldName - name of the field that is not validparentFieldName - name of the parent field that contains fieldNamereason - reason (if known) that fieldName is invalidAwJsonException - always thrownpublic java.lang.String toString()
toString in class java.lang.Object