Class AbstractOpenServiceBrokerObject

    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> JSONArray<T> addToArray​(java.lang.String key, java.lang.Class<T> clazz, T[] values)
      Adds elements to an array.
      <T> JSONArray<T> createArray​(java.lang.String key, java.lang.Class<T> clazz)
      Creates and adds a new array.
      <T> JSONArray<T> createArray​(java.lang.String key, java.lang.Class<T> clazz, T[] values)
      Creates, fills, and adds a new array.
      JSONObject createObject​(java.lang.String key)
      Creates and adds a new object.
      <T> T get​(java.lang.String key, java.lang.Class<T> clazz)
      Gets and casts a value of a field.
      <T> JSONArray<T> getArray​(java.lang.String key, java.lang.Class<T> clazz)
      Gets an array and check if all elements are of the given class.
      java.lang.Boolean getBoolean​(java.lang.String key)
      Gets and casts a value of a field to a Boolean.
      JSONObject getJSONObject​(java.lang.String key)
      Gets and casts a value of a field to a JSONObject.
      java.lang.Long getNumber​(java.lang.String key)
      Gets and casts a value of a field to a Long.
      java.lang.String getString​(java.lang.String key)
      Gets and casts a value of a field to a String.
      boolean isNullOrEmpty​(java.lang.String key)
      Checks if a field value exists, is null, is empty string, or an empty list.
      boolean isValidID​(java.lang.String key)
      Checks if a field value is valid ID as defined in the OSBAPI specification.
      boolean isValidName​(java.lang.String key)
      Checks if a field value is valid CLI name as defined in the OSBAPI specification.
      void load​(java.io.Reader in)
      Loads a JSON into this object.
      void load​(java.lang.String json)
      Loads a JSON into this object.
      void validate()
      Check if the object and its subobjects are in valid state.
      protected void validateSubobjects()
      Walks through all fields in this object and validates their values.
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, remove, replace, replace, size
      • Methods inherited from class de.fmui.osb.broker.internal.json.JSONObjectImpl

        addJSONString, escape, put, toJSONString, toJSONString, toString, toString, writeJSONString, writeJSONString
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractOpenServiceBrokerObject

        public AbstractOpenServiceBrokerObject()
        Default constructor.
      • AbstractOpenServiceBrokerObject

        public AbstractOpenServiceBrokerObject​(java.util.Map<java.lang.String,java.lang.Object> m)
        Constructor with initial values.
        Parameters:
        m - a map containing the initial values of this object
        Throws:
        java.lang.NullPointerException - if the specified map is null
    • Method Detail

      • createObject

        public JSONObject createObject​(java.lang.String key)
        Creates and adds a new object.
        Parameters:
        key - the key of the new object
        Returns:
        the newly created object
      • createArray

        public <T> JSONArray<T> createArray​(java.lang.String key,
                                            java.lang.Class<T> clazz)
        Creates and adds a new array.
        Type Parameters:
        T - the type of the array elements
        Parameters:
        key - the key of the new array
        clazz - the class of the elements of the array
        Returns:
        the newly created array
      • createArray

        public <T> JSONArray<T> createArray​(java.lang.String key,
                                            java.lang.Class<T> clazz,
                                            T[] values)
        Creates, fills, and adds a new array.
        Type Parameters:
        T - the type of the array elements
        Parameters:
        key - the key of the new array
        clazz - the class of the elements of the array
        values - initial values of the array
        Returns:
        the newly created array
      • addToArray

        public <T> JSONArray<T> addToArray​(java.lang.String key,
                                           java.lang.Class<T> clazz,
                                           T[] values)
        Adds elements to an array. If the array doesn't exist, it will be created.
        Type Parameters:
        T - the type of the array elements
        Parameters:
        key - the key of the new array
        clazz - the class of the elements of the array
        values - the values to add
        Returns:
        the updated or created array
      • get

        public <T> T get​(java.lang.String key,
                         java.lang.Class<T> clazz)
        Gets and casts a value of a field.
        Type Parameters:
        T - the type of the value
        Parameters:
        key - the field key
        clazz - the expected class of the value
        Returns:
        the value
      • getArray

        public <T> JSONArray<T> getArray​(java.lang.String key,
                                         java.lang.Class<T> clazz)
        Gets an array and check if all elements are of the given class.
        Type Parameters:
        T - the type of the array elements
        Parameters:
        key - the field key
        clazz - the expected class of the elements in the array
        Returns:
        the array
      • getString

        public java.lang.String getString​(java.lang.String key)
        Gets and casts a value of a field to a String.
        Parameters:
        key - the field key
        Returns:
        the value
      • getNumber

        public java.lang.Long getNumber​(java.lang.String key)
        Gets and casts a value of a field to a Long.
        Parameters:
        key - the field key
        Returns:
        the value
      • getBoolean

        public java.lang.Boolean getBoolean​(java.lang.String key)
        Gets and casts a value of a field to a Boolean.
        Parameters:
        key - the field key
        Returns:
        the value
      • getJSONObject

        public JSONObject getJSONObject​(java.lang.String key)
        Gets and casts a value of a field to a JSONObject.
        Parameters:
        key - the field key
        Returns:
        the JSON object
      • isNullOrEmpty

        public boolean isNullOrEmpty​(java.lang.String key)
        Checks if a field value exists, is null, is empty string, or an empty list.
        Parameters:
        key - the field key
        Returns:
        true if the field does not exist, its value is null or an empty string or an empty list, false otherwise
      • isValidName

        public boolean isValidName​(java.lang.String key)
        Checks if a field value is valid CLI name as defined in the OSBAPI specification.
        Parameters:
        key - the field key
        Returns:
        true if the field exists, its value is string, and the string is a valid CLI name, false otherwise
      • isValidID

        public boolean isValidID​(java.lang.String key)
        Checks if a field value is valid ID as defined in the OSBAPI specification.
        Parameters:
        key - the field key
        Returns:
        true if the field exists, its value is string, and the string is a valid ID, false otherwise
      • validateSubobjects

        protected void validateSubobjects()
                                   throws ValidationException
        Walks through all fields in this object and validates their values.
        Throws:
        ValidationException - if a validation fails
      • load

        public void load​(java.io.Reader in)
                  throws java.io.IOException
        Loads a JSON into this object.
        Parameters:
        in - the reader providing the JSON
        Throws:
        java.io.IOException - if reading or parsing fails
      • load

        public void load​(java.lang.String json)
                  throws java.io.IOException
        Loads a JSON into this object.
        Parameters:
        json - the JSON string
        Throws:
        java.io.IOException - if reading or parsing fails