Class PropertyHelper


  • public class PropertyHelper
    extends Object
    PropertyHelper is used by the governance actions services to manage the contents of the ElementProperties structure. It is a stateless object and so there are no threading concerns with declaring it as a static variable.
    • Constructor Detail

      • PropertyHelper

        public PropertyHelper()
    • Method Detail

      • validateGUID

        public void validateGUID​(String guid,
                                 String guidParameter,
                                 String methodName)
                          throws InvalidParameterException
        Throw an exception if the supplied GUID is null
        Parameters:
        guid - unique identifier to validate
        guidParameter - name of the parameter that passed the guid.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the guid is null
      • validateMandatoryName

        public void validateMandatoryName​(String name,
                                          String nameParameter,
                                          String methodName)
                                   throws InvalidParameterException
        Throw an exception if the supplied name is null
        Parameters:
        name - unique name to validate
        nameParameter - name of the parameter that passed the name.
        methodName - name of the method making the call.
        Throws:
        InvalidParameterException - the name is null
      • addStringProperty

        public ElementProperties addStringProperty​(ElementProperties properties,
                                                   String propertyName,
                                                   String propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        element properties object.
      • addIntProperty

        public ElementProperties addIntProperty​(ElementProperties properties,
                                                String propertyName,
                                                int propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        resulting element properties object
      • addLongProperty

        public ElementProperties addLongProperty​(ElementProperties properties,
                                                 String propertyName,
                                                 long propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        resulting element properties object
      • addFloatProperty

        public ElementProperties addFloatProperty​(ElementProperties properties,
                                                  String propertyName,
                                                  float propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        resulting element properties object
      • addDateProperty

        public ElementProperties addDateProperty​(ElementProperties properties,
                                                 String propertyName,
                                                 Date propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        resulting element properties object
      • addBooleanProperty

        public ElementProperties addBooleanProperty​(ElementProperties properties,
                                                    String propertyName,
                                                    boolean propertyValue)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        propertyValue - value of property
        Returns:
        resulting element properties object
      • addEnumProperty

        public ElementProperties addEnumProperty​(ElementProperties properties,
                                                 String propertyName,
                                                 String propertyType,
                                                 String symbolicName)
        Add the supplied property to an element properties object. If the element property object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        propertyType - type of enum
        symbolicName - symbol name value of property
        Returns:
        resulting element properties object
      • addStringArrayProperty

        public ElementProperties addStringArrayProperty​(ElementProperties properties,
                                                        String propertyName,
                                                        List<String> arrayValues)
        Add the supplied array property to an element properties object. The supplied array is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        arrayValues - contents of the array
        Returns:
        resulting element properties object
      • addMapProperty

        public ElementProperties addMapProperty​(ElementProperties properties,
                                                String propertyName,
                                                Map<String,​Object> mapValues)
        Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        mapValues - contents of the map
        Returns:
        resulting element properties object
      • addPropertyMap

        public ElementProperties addPropertyMap​(ElementProperties properties,
                                                Map<String,​Object> mapValues)
        Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        mapValues - contents of the map
        Returns:
        instance properties object.
      • addStringMapProperty

        public ElementProperties addStringMapProperty​(ElementProperties properties,
                                                      String propertyName,
                                                      Map<String,​String> mapValues)
        Add the supplied map property to an element properties object. The supplied map is stored as a single property in the instances properties. If the element properties object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        propertyName - name of property
        mapValues - contents of the map
        Returns:
        resulting element properties object
      • addStringPropertyMap

        public ElementProperties addStringPropertyMap​(ElementProperties properties,
                                                      Map<String,​String> mapValues)
        Add the supplied property map to an element properties object. Each of the entries in the map is added as a separate property in element properties. If the element properties object supplied is null, a new element properties object is created.
        Parameters:
        properties - properties object to add property to, may be null.
        mapValues - contents of the map
        Returns:
        resulting element properties object
      • getStringMapFromProperty

        public Map<String,​String> getStringMapFromProperty​(String sourceName,
                                                                 String propertyName,
                                                                 ElementProperties properties,
                                                                 String methodName)
        Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
        Parameters:
        sourceName - source of call
        propertyName - name of requested map property
        properties - values of the property
        methodName - method of caller
        Returns:
        map property value or null
      • getBooleanMapFromProperty

        public Map<String,​Boolean> getBooleanMapFromProperty​(String sourceName,
                                                                   String propertyName,
                                                                   ElementProperties properties,
                                                                   String methodName)
        Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
        Parameters:
        sourceName - source of call
        propertyName - name of requested map property
        properties - values of the property
        methodName - method of caller
        Returns:
        map property value or null
      • getLongMapFromProperty

        public Map<String,​Long> getLongMapFromProperty​(String sourceName,
                                                             String propertyName,
                                                             ElementProperties properties,
                                                             String methodName)
        Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
        Parameters:
        sourceName - source of call
        propertyName - name of requested map property
        properties - values of the property
        methodName - method of caller
        Returns:
        map property value or null
      • getIntegerMapFromProperty

        public Map<String,​Integer> getIntegerMapFromProperty​(String sourceName,
                                                                   String propertyName,
                                                                   ElementProperties properties,
                                                                   String methodName)
        Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
        Parameters:
        sourceName - source of call
        propertyName - name of requested map property
        properties - values of the property
        methodName - method of caller
        Returns:
        map property value or null
      • getMapFromProperty

        public Map<String,​Object> getMapFromProperty​(String sourceName,
                                                           String propertyName,
                                                           ElementProperties properties,
                                                           String methodName)
        Locates and extracts a property from an instance that is of type map and then converts its values into a Java map.
        Parameters:
        sourceName - source of call
        propertyName - name of requested map property
        properties - all of the properties of the instance
        methodName - method of caller
        Returns:
        map property value or null
      • getElementPropertiesAsMap

        public Map<String,​Object> getElementPropertiesAsMap​(ElementProperties properties)
        Convert an element properties object into a map.
        Parameters:
        properties - packed properties
        Returns:
        properties stored in Java map
      • getStringProperty

        public String getStringProperty​(String sourceName,
                                        String propertyName,
                                        ElementProperties properties,
                                        String methodName)
        Return the requested property or null if property is not found. If the property is not a string property then a logic exception is thrown
        Parameters:
        sourceName - source of call
        propertyName - name of requested property
        properties - properties from the instance.
        methodName - method of caller
        Returns:
        string property value or null
      • getIntProperty

        public int getIntProperty​(String sourceName,
                                  String propertyName,
                                  ElementProperties properties,
                                  String methodName)
        Return the requested property or 0 if property is not found. If the property is not an int property then a logic exception is thrown.
        Parameters:
        sourceName - source of call
        propertyName - name of requested property
        properties - properties from the instance.
        methodName - method of caller
        Returns:
        string property value or null
      • getDateProperty

        public Date getDateProperty​(String sourceName,
                                    String propertyName,
                                    ElementProperties properties,
                                    String methodName)
        Return the requested property or null if property is not found. If the property is not a date property then a logic exception is thrown.
        Parameters:
        sourceName - source of call
        propertyName - name of requested property
        properties - properties from the instance.
        methodName - method of caller
        Returns:
        string property value or null
      • getBooleanProperty

        public boolean getBooleanProperty​(String sourceName,
                                          String propertyName,
                                          ElementProperties properties,
                                          String methodName)
        Return the requested property or false if property is not found. If the property is not a boolean property then a logic exception is thrown
        Parameters:
        sourceName - source of call
        propertyName - name of requested property
        properties - properties from the instance.
        methodName - method of caller
        Returns:
        string property value or null
      • getSearchProperties

        public SearchProperties getSearchProperties​(ElementProperties properties,
                                                    MatchCriteria matchCriteria)
        Convert the provided instance properties and match criteria into an equivalent SearchProperties object.
        Parameters:
        properties - properties object to convert
        matchCriteria - match criteria to apply
        Returns:
        SearchProperties object.