Class ArcadeExpression

  • All Implemented Interfaces:
    JsonSerializable

    public final class ArcadeExpression
    extends java.lang.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​(java.lang.String expression)
      Creates a new ArcadeExpression object with an expression script.
      ArcadeExpression​(java.lang.String expression, java.lang.String title, java.lang.String name)
      Creates a new ArcadeExpression object.
      ArcadeExpression​(java.lang.String expression, java.lang.String title, java.lang.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​(java.lang.String json)
      Creates an ArcadeExpression instance from a JSON string.
      java.lang.String getExpression()
      Gets the Arcade expression string.
      java.lang.String getName()
      Gets the name that the author uses to refer to the expression.
      ArcadeExpressionReturnType getReturnType()
      Gets the expected return type of the expression.
      java.lang.String getTitle()
      Gets the title that the author uses to describe the expression.
      java.util.Map<java.lang.String,​java.lang.Object> getUnknownJson()
      If this object was created from JSON, this method gets unknown data from the source JSON.
      java.util.Map<java.lang.String,​java.lang.Object> getUnsupportedJson()
      If this object was created from JSON, this method gets unsupported data from the source JSON.
      java.lang.String toJson()
      Serializes this object to a JSON string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArcadeExpression

        public ArcadeExpression​(java.lang.String expression)
        Creates a new ArcadeExpression object with an expression script.

        The getName() and getTitle() will default to empty strings. The getReturnType() will default to ArcadeExpressionReturnType.AUTOMATIC.

        Parameters:
        expression - the Arcade expression to be evaluated; if set to an empty expression string then the evaluation will return null.
        Throws:
        java.lang.IllegalArgumentException - if expression is null
        Since:
        100.11.0
      • ArcadeExpression

        public ArcadeExpression​(java.lang.String expression,
                                java.lang.String title,
                                java.lang.String name)
        Creates a new ArcadeExpression object.

        The getReturnType() will default to ArcadeExpressionReturnType.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 expression
        name - the name of the expression
        Throws:
        java.lang.IllegalArgumentException - if expression is null
        java.lang.IllegalArgumentException - if title is null
        java.lang.IllegalArgumentException - if name is null
        Since:
        100.11.0
    • Method Detail

      • getExpression

        public java.lang.String getExpression()
        Gets the Arcade expression string.
        Returns:
        the Arcade expression string
        Since:
        100.11.0
      • getName

        public java.lang.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 a zero value, or empty string.

        Returns:
        the expected return type of the expression
        Since:
        100.11.0
      • getTitle

        public java.lang.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
        Throws:
        java.lang.IllegalArgumentException - if other is null
        Since:
        100.11.0
      • fromJson

        public static ArcadeExpression fromJson​(java.lang.String json)
        Creates an ArcadeExpression instance from a JSON string.
        Parameters:
        json - a JSON string that represents an ArcadeExpression
        Returns:
        an ArcadeExpression instance
        Throws:
        java.lang.IllegalArgumentException - if json is null or empty
        Since:
        100.11.0
      • toJson

        public java.lang.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 interface JsonSerializable
        Returns:
        a JSON string
      • getUnknownJson

        public java.util.Map<java.lang.String,​java.lang.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 interface JsonSerializable
        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
      • getUnsupportedJson

        public java.util.Map<java.lang.String,​java.lang.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 interface JsonSerializable
        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