Class PropertyUtil


  • public class PropertyUtil
    extends Object
    Utility methods for property validation.
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkDistinct​(String... propertyValuePairs)
      Checks that a set of properties don't share any values.
      static void checkFieldExists​(RecordTokenType type, String propertyName, String... fieldNames)
      Checks that the given field name(s) are valid field names in the given record type.
      static void checkFieldExists​(RecordTokenType type, String propertyName, List<String> fieldNames)
      Checks that the given field name(s) are valid field names in the given record type.
      static Set<String> checkNoDuplicates​(String propertyName, String[] propertyValues)
      Checks that a property's array of values contains no duplicates and collects the tested values into a Set.
      static void checkNotEmpty​(String propertyName, Object[] propertyValues)
      Checks that a property's array of values is not null or zero-length.
      static void checkNotEmpty​(String propertyName, String propertyValue)
      Checks that a property's string value is not null or zero-length.
      static void checkNotEmpty​(String propertyName, Collection<?> propertyValues)
      Checks that a property's collection of values is not null or empty.
      static void checkNotNull​(String propertyName, Object propertyValue)
      Checks that a property value is not null.
      static void checkNumericMaxValuesByType​(String propertyName, ScalarTokenType outputType, BigDecimal value)
      Checks that a numeric property value is not greater than the allowed maximum value for the given numeric type, which includes, TokenTypeConstant.INT, DOUBLE, FLOAT, NUMERIC, LONG, MONEY.
      static void checkPropertyGE​(String propertyName, double propertyValue, double minValue)
      Checks that a property value is greater than or equal to a minimum.
      static void checkPropertyGE​(String propertyName, long propertyValue, long minValue)
      Checks that a property value is greater than or equal to a minimum.
      static void checkPropertyGELE​(String propertyName, double propertyValue, double minValue, double maxValue)
      Checks that a property value is greater than or equal to a minimum and less than or equal to a maximum.
      static void checkPropertyGELE​(String propertyName, long propertyValue, long minValue, long maxValue)
      Checks that a property value is greater than or equal to a minimum and less than or equal to a maximum.
      static void checkPropertyGT​(String propertyName, double propertyValue, double minValue)
      Checks that a property value is greater than a minimum.
      static void checkPropertyGT​(String propertyName, long propertyValue, long minValue)
      Checks that a property value is greater than a minimum.
      static void checkPropertyLE​(String propertyName, double propertyValue, double maxValue)
      Checks that a property value is less than or equal to a maximum.
      static void checkPropertyLE​(String propertyName, long propertyValue, long maxValue)
      Checks that a property value is less than or equal to a maximum.
      static void checkPropertyLT​(String propertyName, double propertyValue, double maxValue)
      Checks that a property value is less than a maximum.
      static void checkPropertyLT​(String propertyName, long propertyValue, long maxValue)
      Checks that a property value is less than a maximum.
      static void checkSameSize​(String primaryName, Object primaryArray, String secondaryName, Object secondaryArray)
      Checks that two array properties have the same size.
      static void checkSameSize​(String primaryName, Object primaryArray, String secondaryName, Collection<?> secondaryCollection)
      Checks that an array and a collection property both have the same size.
      static void checkSameSize​(String primaryName, Collection<?> primaryCollection, String secondaryName, Object secondaryArray)
      Checks that a collection and an array property both have the same size.
      static void checkSameSize​(String primaryName, Collection<?> primaryCollection, String secondaryName, Collection<?> secondaryCollection)
      Checks that two collection properties have the same size.
      static long parseByteSizeSpecifier​(String propertyName, String specifier)
      Parses the given property as a size in bytes.
    • Constructor Detail

      • PropertyUtil

        public PropertyUtil()
    • Method Detail

      • checkPropertyGE

        public static void checkPropertyGE​(String propertyName,
                                           long propertyValue,
                                           long minValue)
        Checks that a property value is greater than or equal to a minimum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is less than the minimum allowed value.
      • checkPropertyGE

        public static void checkPropertyGE​(String propertyName,
                                           double propertyValue,
                                           double minValue)
        Checks that a property value is greater than or equal to a minimum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value range
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is less than minimum allowed value.
      • checkPropertyGT

        public static void checkPropertyGT​(String propertyName,
                                           long propertyValue,
                                           long minValue)
        Checks that a property value is greater than a minimum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value range
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is less than the minimum allowed value.
      • checkPropertyGT

        public static void checkPropertyGT​(String propertyName,
                                           double propertyValue,
                                           double minValue)
        Checks that a property value is greater than a minimum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is less than minimum allowed value.
      • checkPropertyLE

        public static void checkPropertyLE​(String propertyName,
                                           long propertyValue,
                                           long maxValue)
        Checks that a property value is less than or equal to a maximum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        maxValue - the maximum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is greater than maximum allowed value.
      • checkPropertyLE

        public static void checkPropertyLE​(String propertyName,
                                           double propertyValue,
                                           double maxValue)
        Checks that a property value is less than or equal to a maximum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        maxValue - the maximum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is greater than maximum allowed value.
      • checkNumericMaxValuesByType

        public static void checkNumericMaxValuesByType​(String propertyName,
                                                       ScalarTokenType outputType,
                                                       BigDecimal value)
        Checks that a numeric property value is not greater than the allowed maximum value for the given numeric type, which includes, TokenTypeConstant.INT, DOUBLE, FLOAT, NUMERIC, LONG, MONEY.
        Parameters:
        propertyName - the name of the numeric property
        outputType - the type of the property
        value - the value of the property wrapped as a BigDecimal.
      • checkPropertyLT

        public static void checkPropertyLT​(String propertyName,
                                           long propertyValue,
                                           long maxValue)
        Checks that a property value is less than a maximum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        maxValue - the upper range value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is not less than an upper range.
      • checkPropertyLT

        public static void checkPropertyLT​(String propertyName,
                                           double propertyValue,
                                           double maxValue)
        Checks that a property value is less than a maximum.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        maxValue - the upper range value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is not less than an upper range.
      • checkPropertyGELE

        public static void checkPropertyGELE​(String propertyName,
                                             long propertyValue,
                                             long minValue,
                                             long maxValue)
        Checks that a property value is greater than or equal to a minimum and less than or equal to a maximum.

        This is a convenience method which combines checkPropertyGE(String, long, long) and checkPropertyLE(String, long, long).

        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value allowed
        maxValue - the maximum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is outside the specified range.
      • checkPropertyGELE

        public static void checkPropertyGELE​(String propertyName,
                                             double propertyValue,
                                             double minValue,
                                             double maxValue)
        Checks that a property value is greater than or equal to a minimum and less than or equal to a maximum.

        This is a convenience method which combines checkPropertyGE(String, double, double) and checkPropertyLE(String, double, double).

        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        minValue - the minimum value allowed
        maxValue - the maximum value allowed
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is outside the specified range.
      • checkNotNull

        public static void checkNotNull​(String propertyName,
                                        Object propertyValue)
        Checks that a property value is not null.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value to check
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValue is null.
      • checkNotEmpty

        public static void checkNotEmpty​(String propertyName,
                                         String propertyValue)
        Checks that a property's string value is not null or zero-length.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValue - the property value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValues is null or zero-length.
      • checkNotEmpty

        public static void checkNotEmpty​(String propertyName,
                                         Object[] propertyValues)
        Checks that a property's array of values is not null or zero-length.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValues - the property array to check
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValues is null or zero-length.
      • checkDistinct

        public static void checkDistinct​(String... propertyValuePairs)
        Checks that a set of properties don't share any values.
        Parameters:
        propertyValuePairs - Pairs of properties and their values [property1,value1,property2,value2,...].
      • checkNoDuplicates

        public static Set<String> checkNoDuplicates​(String propertyName,
                                                    String[] propertyValues)
        Checks that a property's array of values contains no duplicates and collects the tested values into a Set.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValues - the property array to check
        Returns:
        a set representation of the values in propertyValues
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValues contains duplicates.
      • checkSameSize

        public static void checkSameSize​(String primaryName,
                                         Collection<?> primaryCollection,
                                         String secondaryName,
                                         Collection<?> secondaryCollection)
        Checks that two collection properties have the same size.
        Parameters:
        primaryName - the first collection property's name
        primaryCollection - the first collection property's value
        secondaryName - the second collection property's name
        secondaryCollection - the second collection property's value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if properties have different number of elements.
      • checkSameSize

        public static void checkSameSize​(String primaryName,
                                         Object primaryArray,
                                         String secondaryName,
                                         Object secondaryArray)
        Checks that two array properties have the same size.
        Parameters:
        primaryName - the first array property's name
        primaryArray - the first array property's value
        secondaryName - the second array property's name
        secondaryArray - the second array property's value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if properties have different number of elements.
      • checkSameSize

        public static void checkSameSize​(String primaryName,
                                         Collection<?> primaryCollection,
                                         String secondaryName,
                                         Object secondaryArray)
        Checks that a collection and an array property both have the same size.
        Parameters:
        primaryName - the collection property's name
        primaryCollection - the collection property's value
        secondaryName - the array property's name
        secondaryArray - the array property's value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if properties have different number of elements.
      • checkSameSize

        public static void checkSameSize​(String primaryName,
                                         Object primaryArray,
                                         String secondaryName,
                                         Collection<?> secondaryCollection)
        Checks that an array and a collection property both have the same size.
        Parameters:
        primaryName - the array property's name
        primaryArray - the array property's value
        secondaryName - the collection property's name
        secondaryCollection - the collection property's value
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if properties have different number of elements.
      • checkNotEmpty

        public static void checkNotEmpty​(String propertyName,
                                         Collection<?> propertyValues)
        Checks that a property's collection of values is not null or empty.
        Parameters:
        propertyName - the name of the property, used in any generated error messages
        propertyValues - the property collection to check
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if propertyValues is null or empty.
      • checkFieldExists

        public static void checkFieldExists​(RecordTokenType type,
                                            String propertyName,
                                            String... fieldNames)
        Checks that the given field name(s) are valid field names in the given record type. Invalid field names are reported using an InvalidPropertyValueException.
        Parameters:
        type - the record type to check
        propertyName - name of the property containing the field names
        fieldNames - field names to verify exist
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - thrown if any of the given field names are invalid
      • checkFieldExists

        public static void checkFieldExists​(RecordTokenType type,
                                            String propertyName,
                                            List<String> fieldNames)
        Checks that the given field name(s) are valid field names in the given record type. Invalid field names are reported using an InvalidPropertyValueException.
        Parameters:
        type - the record type to check
        propertyName - name of the property containing the field names
        fieldNames - field names to verify exist
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - thrown if any of the given field names are invalid
      • parseByteSizeSpecifier

        public static long parseByteSizeSpecifier​(String propertyName,
                                                  String specifier)
        Parses the given property as a size in bytes. Values are supplied as number strings, supporting an optional size suffix. The common suffixes K, M, and G are supported, having the expected meaning; suffixes are case-insensitive. Omitting the suffix indicates the value is in bytes.
        Parameters:
        propertyName - the name of the property, used for error handling
        specifier - the specifier. for example "100M"
        Returns:
        the size in bytes
        Throws:
        com.pervasive.datarush.graphs.physical.InvalidPropertyValueException - if the size specifier cannot be parsed or specifies a negative size.