Value - public abstract class ReflectiveAttribute<Value> extends java.lang.Object implements Attribute
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JSON_ATTRIBUTE_DEFAULT
The default value of the attribute param in the optional params.
|
static java.lang.String |
JSON_ATTRIBUTE_EMBEDDED_TYPE
If the parameter in the value object is another value object (and not a PObject or PArray) then this
will be a json object describing the embedded param in the same way as each object in clientParams.
|
static java.lang.String |
JSON_ATTRIBUTE_IS_ARRAY
Json field that declares if the param is an array.
|
static java.lang.String |
JSON_ATTRIBUTE_TYPE
A string describing the type of the attribute param in the clientConfig.
|
static java.lang.String |
JSON_CLIENT_INFO
Name of the value suggestions object in the client config json.
|
static java.lang.String |
JSON_CLIENT_PARAMS
Name of the required parameters object in the client config json.
|
static java.lang.String |
JSON_NAME
Name of attribute in the client config json.
|
| Constructor and Description |
|---|
ReflectiveAttribute() |
| Modifier and Type | Method and Description |
|---|---|
abstract Value |
createValue(Template template)
Create an instance of a attribute value object.
|
protected java.lang.String |
getAttributeName()
Return a descriptive name of this attribute.
|
protected java.util.Optional<org.json.JSONObject> |
getClientInfo()
Return an object that will be added to the client config with the key clientInfo.
|
PObject |
getDefaultValue()
The YAML config default values.
|
java.lang.Object |
getValue(Template template,
java.lang.String attributeName,
PObject requestJsonAttributes)
Get the attribute value.
|
abstract java.lang.Class<? extends Value> |
getValueType()
Return the type created by
createValue(Template). |
void |
printClientConfig(org.json.JSONWriter json,
Template template)
Uses reflection on the object created by
createValue(Template) to
create the options. |
void |
setConfigName(java.lang.String configName)
Set the name of the attribute as set in the configuration file.
|
void |
setDefault(java.util.Map<java.lang.String,java.lang.Object> defaultValue)
Default values for this attribute.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvalidatepublic static final java.lang.String JSON_NAME
public static final java.lang.String JSON_CLIENT_PARAMS
public static final java.lang.String JSON_CLIENT_INFO
public static final java.lang.String JSON_ATTRIBUTE_TYPE
public static final java.lang.String JSON_ATTRIBUTE_EMBEDDED_TYPE
public static final java.lang.String JSON_ATTRIBUTE_DEFAULT
public static final java.lang.String JSON_ATTRIBUTE_IS_ARRAY
public abstract java.lang.Class<? extends Value> getValueType()
createValue(Template).getValueType in interface Attributepublic final PObject getDefaultValue()
public final void setDefault(java.util.Map<java.lang.String,java.lang.Object> defaultValue)
Default values for this attribute. Example:
attributes:
legend: !legend
default:
name: "Legend"defaultValue - The default values.public final void setConfigName(java.lang.String configName)
AttributesetConfigName in interface AttributeconfigName - the name of the attributeprotected final java.lang.String getAttributeName()
public abstract Value createValue(Template template)
HasDefaultValue annotation then no
exception will be thrown if the json does not contain a value.
Fields in the object with the OneOf annotation must have one of the
fields in the request data.
StringIntegerFloatDoubleShortBooleanCharacterByteEnum()
method then it will be called after the fields are all set.
In the case where the a parameter type is a normal POJO (not a special case like PJsonObject, URL,
enum, double, etc...) then it will be assumed that the json data is a json object and the parameters
will be recursively parsed into the new object as if it is also MapLayer parameter object.
It is important to put values in the value object as public fields because reflection is used when
printing client config as well as generating documentation. If a field is intended for the client
software as information but is not intended to be set (or sent as part of the request data), the field
can be a final field.template - the template that this attribute is part of.public final void printClientConfig(org.json.JSONWriter json,
Template template)
throws org.json.JSONException
createValue(Template) to
create the options.
The public final fields are written as the field name as the key and the value as the value.
The public (non-final) mandatory fields are written as part of clientParams and are written with the
field name as the key and the field type as the value.
The public (non-final) HasDefaultValue fields are written as part of
clientOptions and are written with the field name as the key and an object as a value with a type
property with the type and a default property containing the default value.printClientConfig in interface Attributejson - the json writer to write totemplate - the template that this attribute is part oforg.json.JSONExceptionprotected java.util.Optional<org.json.JSONObject> getClientInfo()
throws org.json.JSONException
org.json.JSONException