Class JSValueImpl

    • Field Detail

      • factory

        protected static final JSFactory factory
      • type

        protected final String type
    • Constructor Detail

      • JSValueImpl

        public JSValueImpl​(String type,
                           com.fasterxml.jackson.databind.JsonNode node)
      • JSValueImpl

        protected JSValueImpl()
        Only used for proxies.
    • Method Detail

      • getObjectType

        public String getObjectType()
        Specified by:
        getObjectType in interface JSValue
        Returns:
        type passed to constructor
      • getNode

        public com.fasterxml.jackson.databind.JsonNode getNode()
        Specified by:
        getNode in interface JSValue
        Returns:
        node which currently represents this object
      • preWrite

        public void preWrite()
        Description copied from interface: JSValue
        Called before we output the object. Objects MUST call all children to allow any processing before output - e.g. generate patches.
        Specified by:
        preWrite in interface JSValue
      • getFactory

        protected JSFactory getFactory()
      • setOwner

        public void setOwner​(JSValue val)
        The owner is the value containing this value.
        Parameters:
        val - the owner of this value
      • getOwner

        public JSValue getOwner()
        Specified by:
        getOwner in interface JSValue
        Returns:
        next value up in hierarchy
      • setParentProperty

        public void setParentProperty​(JSProperty<?> val)
        The owner is the property containing the value.
        Parameters:
        val - the property containing the value
      • getChanged

        public boolean getChanged()
        Specified by:
        getChanged in interface JSValue
        Returns:
        true if this value was changed - i.e a value was changed or a sub-property added or removed.
      • markOverrideGenerated

        public void markOverrideGenerated()
        Description copied from interface: JSValue
        Flags this value is being generated for overrides. Will be skipped when generating patches.
        Specified by:
        markOverrideGenerated in interface JSValue
      • getOverrideGenerated

        public boolean getOverrideGenerated()
        Specified by:
        getOverrideGenerated in interface JSValue
        Returns:
        true if this is generated for overrides.
      • hasChanges

        public boolean hasChanges()
        Specified by:
        hasChanges in interface JSValue
        Returns:
        true if this or any sub-value was changed.
      • setMasterCopy

        protected void setMasterCopy​(com.fasterxml.jackson.databind.JsonNode copyNode)
      • getType

        public String getType()
        Specified by:
        getType in interface JSValue
        Returns:
        the type of the value
      • hasProperty

        public boolean hasProperty​(String propertyName)
        Specified by:
        hasProperty in interface JSValue
        Parameters:
        propertyName - to test for
        Returns:
        true if value contains named property
      • getProperties

        public List<JSProperty<?>> getProperties()
        Description copied from interface: JSValue
        Return all contained properties
        Specified by:
        getProperties in interface JSValue
        Returns:
        properties throws JsforjException if not an object
      • getProperty

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

        public JSProperty<?> getProperty​(String name)
        Description copied from interface: JSValue
        Return named property
        Specified by:
        getProperty in interface JSValue
        Parameters:
        name - of property
        Returns:
        property or null throws JsforjException if not an object
      • getPropertyValue

        public JSValue getPropertyValue​(String name)
        Description copied from interface: JSValue
        Get the value. Return null if absent.
        Specified by:
        getPropertyValue in interface JSValue
        Parameters:
        name - of property
        Returns:
        the value or null
      • getStringProperty

        public String getStringProperty​(String name)
        Description copied from interface: JSValue
        Returns value of named String property.
        Specified by:
        getStringProperty in interface JSValue
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property throws JsforjException if not a String property
      • getBooleanProperty

        public boolean getBooleanProperty​(String name)
        Description copied from interface: JSValue
        Returns value of named boolean property.
        Specified by:
        getBooleanProperty in interface JSValue
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property - false if absent throws JsforjException if not a boolean property
      • isString

        public boolean isString()
        Specified by:
        isString in interface JSValue
        Returns:
        true if this is a string
      • getUnsignedIntegerProperty

        public JSUnsignedInteger getUnsignedIntegerProperty​(String name)
        Description copied from interface: JSValue
        Returns value of named UnsignedInteger property.
        Specified by:
        getUnsignedIntegerProperty in interface JSValue
        Parameters:
        name - the property name - non null
        Returns:
        the value of the property throws JsforjException if not a String property
      • getStringValue

        public String getStringValue()
        Description copied from interface: JSValue
        Returns value as a String.
        Specified by:
        getStringValue in interface JSValue
        Returns:
        the value of the property throws JsforjException if not a String property
      • getBooleanValue

        public boolean getBooleanValue()
        Description copied from interface: JSValue
        Returns value as a boolean.
        Specified by:
        getBooleanValue in interface JSValue
        Returns:
        the value of the property throws JsforjException if not a boolean property
      • getValue

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

        public void writeValue​(Writer wtr,
                               com.fasterxml.jackson.databind.ObjectMapper mapper)
        Description copied from interface: JSValue
        Convert to json with this as root
        Specified by:
        writeValue in interface JSValue
        Parameters:
        wtr - to write to
        mapper - to convert
      • writeValueAsString

        public String writeValueAsString​(com.fasterxml.jackson.databind.ObjectMapper mapper)
        Description copied from interface: JSValue
        Convert to json with this as root
        Specified by:
        writeValueAsString in interface JSValue
        Parameters:
        mapper - to convert
        Returns:
        Json
      • writeValueAsStringFormatted

        public String writeValueAsStringFormatted​(com.fasterxml.jackson.databind.ObjectMapper mapper)
        Description copied from interface: JSValue
        Convert to formatted json with this as root
        Specified by:
        writeValueAsStringFormatted in interface JSValue
        Parameters:
        mapper - to convert
        Returns:
        Json
      • newProperty

        public <T extends JSValueJSProperty<T> newProperty​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef,
                                                             String name,
                                                             String type)
        Description copied from interface: JSValue
        Create a property of the given type. NOT added or set
        Specified by:
        newProperty in interface JSValue
        name - the property name - non null
        type - the property type
        Returns:
        the property throws JsforjException if property already exists
      • removeProperty

        public void removeProperty​(String name)
        Description copied from interface: JSValue
        Remove named property throws JsforjException if not an object
        Specified by:
        removeProperty in interface JSValue
      • clear

        public void clear()
        Description copied from interface: JSValue
        Remove all contained properties and values
        Specified by:
        clear in interface JSValue
      • setProperty

        public <ValType extends JSValueJSProperty<ValType> setProperty​(JSProperty<ValType> val)
        Description copied from interface: JSValue
        Add or replace the named property
        Specified by:
        setProperty in interface JSValue
        Parameters:
        val - the property - non null
        Returns:
        the property
      • setProperty

        public JSProperty<JSString> setProperty​(String name,
                                                String val)
        Description copied from interface: JSValue
        Set the value for a string type property
        Specified by:
        setProperty in interface JSValue
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • setProperty

        public JSProperty<?> setProperty​(String name,
                                         JSValue val)
        Description copied from interface: JSValue
        Set the value for an JSValue type property
        Specified by:
        setProperty in interface JSValue
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • setProperty

        public JSProperty<?> setProperty​(String name,
                                         Integer val)
        Description copied from interface: JSValue
        Set the value for an UnsignedInteger type property
        Specified by:
        setProperty in interface JSValue
        Parameters:
        name - the property name - non null
        val - the property value - non null
        Returns:
        the property
      • setProperty

        public JSProperty<?> setProperty​(String name,
                                         boolean val)
        Description copied from interface: JSValue
        Set the value for a boolean type property
        Specified by:
        setProperty in interface JSValue
        Parameters:
        name - the property name - non null
        val - the property value
        Returns:
        the property
      • makeProperty

        public <T extends JSValueJSProperty<T> makeProperty​(com.fasterxml.jackson.core.type.TypeReference<T> typeRef,
                                                              String name,
                                                              String type)
        Description copied from interface: JSValue
        Add a property of given type.
        Specified by:
        makeProperty in interface JSValue
        name - the property name - non null
        type - the property type
        Returns:
        the property throws JsforjException if property already exists
      • makeProperty

        protected JSProperty<?> makeProperty​(String name,
                                             com.fasterxml.jackson.databind.JsonNode node)
      • assertStringNode

        protected void assertStringNode()
      • assertIntNode

        protected void assertIntNode()
      • assertBooleanNode

        protected void assertBooleanNode()
      • assertObject

        protected void assertObject​(String action)
      • assertArray

        protected void assertArray​(String action)