Class ArcadeExpression
- java.lang.Object
-
- com.esri.arcgisruntime.arcade.ArcadeExpression
-
- All Implemented Interfaces:
JsonSerializable
public final class ArcadeExpression extends Object implements JsonSerializable
An Arcade expression, containing an expression, a name, a return type and a title.An ArcadeExpression object gathers an Arcade script expression together with:
- the expected return type
- the name that a map author uses to refer to it
- the title that the author uses to describe the expression.
- Since:
- 100.11.0
-
-
Constructor Summary
Constructors Constructor Description ArcadeExpression(String expression)
Creates a new ArcadeExpression object with an expression script.ArcadeExpression(String expression, String title, String name)
Creates a new ArcadeExpression object.ArcadeExpression(String expression, String title, String name, ArcadeExpressionReturnType returnType)
Creates a new ArcadeExpression object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(ArcadeExpression other)
Tests if two ArcadeExpression objects are equal.static ArcadeExpression
fromJson(String json)
Creates an ArcadeExpression instance from a JSON string.String
getExpression()
Gets the Arcade expression string.String
getName()
Gets the name that the author uses to refer to the expression.ArcadeExpressionReturnType
getReturnType()
Gets the expected return type of the expression.String
getTitle()
Gets the title that the author uses to describe the expression.Map<String,Object>
getUnknownJson()
If this object was created from JSON, this method gets unknown data from the source JSON.Map<String,Object>
getUnsupportedJson()
If this object was created from JSON, this method gets unsupported data from the source JSON.String
toJson()
Serializes this object to a JSON string.
-
-
-
Constructor Detail
-
ArcadeExpression
public ArcadeExpression(String expression)
Creates a new ArcadeExpression object with an expression script.The
getName()
andgetTitle()
will default to empty strings. ThegetReturnType()
will default toArcadeExpressionReturnType.AUTOMATIC
.- Parameters:
expression
- the Arcade expression to be evaluated; if set to an empty expression string then the evaluation will return null.- Throws:
IllegalArgumentException
- if expression is null- Since:
- 100.11.0
-
ArcadeExpression
public ArcadeExpression(String expression, String title, String name)
Creates a new ArcadeExpression object.The
getReturnType()
will default toArcadeExpressionReturnType.AUTOMATIC
.- Parameters:
expression
- the Arcade expression to be evaluated; if set to an empty expression string then the evaluation will return null.title
- the title of the expressionname
- the name of the expression- Throws:
IllegalArgumentException
- if expression is nullIllegalArgumentException
- if title is nullIllegalArgumentException
- if name is null- Since:
- 100.11.0
-
ArcadeExpression
public ArcadeExpression(String expression, String title, String name, ArcadeExpressionReturnType returnType)
Creates a new ArcadeExpression object.If set to an empty expression string then the evaluation will calculate zero, an empty string, or null, depending on whether the
ArcadeExpressionReturnType
is one of the following:ArcadeExpressionReturnType.NUMBER
,ArcadeExpressionReturnType.STRING
,ArcadeExpressionReturnType.AUTOMATIC
,ArcadeExpressionReturnType.ANY
,ArcadeExpressionReturnType.BOOLEAN
.- Parameters:
expression
- the Arcade expression to be evaluated. If set to an empty expression string, then the evaluation will return zero, false, an empty string, or null, depending on whether the returnType isArcadeExpressionReturnType.NUMBER
,ArcadeExpressionReturnType.BOOLEAN
,ArcadeExpressionReturnType.STRING
or anything else, respectively.title
- the title of the expressionname
- the name of the expressionreturnType
- If the Arcade expression creates results of a different type (e.g., a Date or an Array), then the result will be cast to the expected return type. If no sensible cast can be carried out, then the result will be null.- Throws:
IllegalArgumentException
- if expression is nullIllegalArgumentException
- if title is nullIllegalArgumentException
- if name is nullIllegalArgumentException
- if returnType is null- Since:
- 100.11.0
-
-
Method Detail
-
getExpression
public String getExpression()
Gets the Arcade expression string.- Returns:
- the Arcade expression string
- Since:
- 100.11.0
-
getName
public String getName()
Gets the name that the author uses to refer to the expression.If not set explicitly, then the default is an empty string.
- Returns:
- the name of the expression
- Since:
- 100.11.0
-
getReturnType
public ArcadeExpressionReturnType getReturnType()
Gets the expected return type of the expression.If the arcade expression creates results of a different type (for example, a Date or an Array) then the result will be cast to the expected return type. If no sensible cast can be carried out, then the result will be null.
- Returns:
- the expected return type of the expression
- Since:
- 100.11.0
-
getTitle
public String getTitle()
Gets the title that the author uses to describe the expression.If not set explicitly, then the default is an empty string.
- Returns:
- the title
- Since:
- 100.11.0
-
equals
public boolean equals(ArcadeExpression other)
Tests if two ArcadeExpression objects are equal.- Parameters:
other
- the second object- Returns:
- true if this ArcadeExpression and the other ArcadeExpression are equivalent, false if they are not
- Since:
- 100.11.0
-
fromJson
public static ArcadeExpression fromJson(String json)
Creates an ArcadeExpression instance from a JSON string.- Parameters:
json
- a JSON string that represents an ArcadeExpression- Returns:
- an ArcadeExpression instance
- Throws:
IllegalArgumentException
- if json is null or empty- Since:
- 100.11.0
-
toJson
public String toJson()
Description copied from interface:JsonSerializable
Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.- Specified by:
toJson
in interfaceJsonSerializable
- Returns:
- a JSON string
-
getUnknownJson
public Map<String,Object> getUnknownJson()
Description copied from interface:JsonSerializable
If this object was created from JSON, this method gets unknown data from the source JSON. Unknown JSON is a Map of values that were in the source JSON but are not known by the Runtime and therefore not exposed in the API.- Specified by:
getUnknownJson
in interfaceJsonSerializable
- Returns:
- an unmodifiable Map containing unknown JSON data. The keys are Strings containing names. The types of
the values depend on the types of tokens within the JSON as follows:
- a
Map<String, Object>
represents an object in the JSON - a
List<Object>
represents an array in the JSON - a
String
represents a string in the JSON - a
Double
represents a number in the JSON - a
Boolean
represents true or false in the JSON null
represents null in the JSON
- a
-
getUnsupportedJson
public Map<String,Object> getUnsupportedJson()
Description copied from interface:JsonSerializable
If this object was created from JSON, this method gets unsupported data from the source JSON. Unsupported JSON is a Map of values that are supported by webmaps and known to the version of the webmap specification the API supports (see system requirements), but are not explicitly exposed through the Runtime API.- Specified by:
getUnsupportedJson
in interfaceJsonSerializable
- Returns:
- an unmodifiable Map containing unsupported JSON data. The keys are Strings containing names. The types of
the values depend on the types of tokens within the JSON as follows:
- a
Map<String, Object>
represents an object in the JSON - a
List<Object>
represents an array in the JSON - a
String
represents a string in the JSON - a
Double
represents a number in the JSON - a
Boolean
represents true or false in the JSON null
represents null in the JSON
- a
-
-