Interface JSValue

    • Method Detail

      • markOverrideGenerated

        void markOverrideGenerated()
        Flags this value is being generated for overrides. Will be skipped when generating patches.
      • getOverrideGenerated

        boolean getOverrideGenerated()
        Returns:
        true if this is generated for overrides.
      • getObjectType

        String getObjectType()
        Returns:
        type passed to constructor
      • getNode

        com.fasterxml.jackson.databind.JsonNode getNode()
        Returns:
        node which currently represents this object
      • preWrite

        void preWrite()
        Called before we output the object. Objects MUST call all children to allow any processing before output - e.g. generate patches.
      • getChanged

        boolean getChanged()
        Returns:
        true if this value was changed - i.e a value was changed or a sub-property added or removed.
      • hasChanges

        boolean hasChanges()
        Returns:
        true if this or any sub-value was changed.
      • getOwner

        JSValue getOwner()
        Returns:
        next value up in hierarchy
      • getParentProperty

        JSProperty<?> getParentProperty()
        Returns:
        property containing this value.
      • getType

        String getType()
        Returns:
        the type of the value
      • hasProperty

        boolean hasProperty​(String propertyName)
        Parameters:
        propertyName - to test for
        Returns:
        true if value contains named property
      • getProperties

        List<JSProperty<?>> getProperties()
        Return all contained properties
        Returns:
        properties throws JsforjException if not an object
      • getProperty

        <T extends JSValueJSProperty<T> getProperty​(com.fasterxml.jackson.core.type.TypeReference<T> type,
                                                      String name)
        Return named property
        Parameters:
        type - expected type
        name - of property
        Returns:
        property or null throws JsforjException if not an object
      • getProperty

        JSProperty<?> getProperty​(String name)
        Return named property
        Parameters:
        name - of property
        Returns:
        property or null throws JsforjException if not an object
      • copy

        default JSValue copy()
        Return a deep copy of this value
        Returns:
        value
      • removeProperty

        void removeProperty​(String name)
        Remove named property throws JsforjException if not an object
      • clear

        void clear()
        Remove all contained properties and values
      • setProperty

        <ValType extends JSValueJSProperty<ValType> setProperty​(JSProperty<ValType> val)
        Add or replace the named property
        Parameters:
        val - the property - non null
        Returns:
        the property
      • setProperty

        JSProperty<?> setProperty​(String name,
                                  String val)
        Set the value for a string type property
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • getPropertyValue

        JSValue getPropertyValue​(String name)
        Get the value. Return null if absent.
        Parameters:
        name - of property
        Returns:
        the value or null
      • getBooleanProperty

        boolean getBooleanProperty​(String name)
        Returns value of named boolean property.
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property - false if absent throws JsforjException if not a boolean property
      • getStringProperty

        String getStringProperty​(String name)
        Returns value of named String property.
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property throws JsforjException if not a String property
      • isString

        boolean isString()
        Returns:
        true if this is a string
      • setProperty

        JSProperty<?> setProperty​(String name,
                                  JSValue val)
        Set the value for an JSValue type property
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • setProperty

        JSProperty<?> setProperty​(String name,
                                  Integer val)
        Set the value for an UnsignedInteger type property
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • setProperty

        JSProperty<?> setProperty​(String name,
                                  boolean val)
        Set the value for a boolean type property
        Parameters:
        name - the property name - non null
        val - the property value
        Returns:
        the property
      • makeProperty

        <T extends JSValueJSProperty<T> makeProperty​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef,
                                                       String name,
                                                       String type)
        Add a property of given type.
        Parameters:
        name - the property name - non null
        type - the property type
        Returns:
        the property throws JsforjException if property already exists
      • newProperty

        <T extends JSValueJSProperty<T> newProperty​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef,
                                                      String name,
                                                      String type)
        Create a property of the given type. NOT added or set
        Parameters:
        name - the property name - non null
        type - the property type
        Returns:
        the property throws JsforjException if property already exists
      • getUnsignedIntegerProperty

        JSUnsignedInteger getUnsignedIntegerProperty​(String name)
        Returns value of named UnsignedInteger property.
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property throws JsforjException if not a String property
      • getStringValue

        String getStringValue()
        Returns value as a String.
        Returns:
        the value of the property throws JsforjException if not a String property
      • getBooleanValue

        boolean getBooleanValue()
        Returns value as a boolean.
        Returns:
        the value of the property throws JsforjException if not a boolean property
      • writeValue

        void writeValue​(Writer wtr,
                        com.fasterxml.jackson.databind.ObjectMapper mapper)
        Convert to json with this as root
        Parameters:
        wtr - to write to
        mapper - to convert
      • writeValueAsString

        String writeValueAsString​(com.fasterxml.jackson.databind.ObjectMapper mapper)
        Convert to json with this as root
        Parameters:
        mapper - to convert
        Returns:
        Json
      • writeValueAsStringFormatted

        String writeValueAsStringFormatted​(com.fasterxml.jackson.databind.ObjectMapper mapper)
        Convert to formatted json with this as root
        Parameters:
        mapper - to convert
        Returns:
        Json
      • getValue

        <T extends JSValue> T getValue​(com.fasterxml.jackson.core.type.TypeReference<T> type,
                                       String pname,
                                       boolean create)
        Returns a value of the desired type and adds as a sub-property of this value.
        Type Parameters:
        T - type of value
        Parameters:
        type - reference
        pname - property name
        create - true if it shoudl be created if absent
        Returns:
        value