- java.lang.Object
-
- com.pervasive.datarush.util.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 aSet
.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.
-
-
-
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 messagespropertyValue
- the property value to checkminValue
- the minimum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkminValue
- the minimum value range- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkminValue
- the minimum value range- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkminValue
- the minimum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkmaxValue
- the maximum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkmaxValue
- the maximum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 propertyoutputType
- the type of the propertyvalue
- the value of the property wrapped as aBigDecimal
.
-
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 messagespropertyValue
- the property value to checkmaxValue
- the upper range value- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to checkmaxValue
- the upper range value- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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)
andcheckPropertyLE(String, long, long)
.- Parameters:
propertyName
- the name of the property, used in any generated error messagespropertyValue
- the property value to checkminValue
- the minimum value allowedmaxValue
- the maximum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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)
andcheckPropertyLE(String, double, double)
.- Parameters:
propertyName
- the name of the property, used in any generated error messagespropertyValue
- the property value to checkminValue
- the minimum value allowedmaxValue
- the maximum value allowed- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value to check- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValue
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 messagespropertyValue
- the property value- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValues
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 messagespropertyValues
- the property array to check- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValues
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 aSet
.- Parameters:
propertyName
- the name of the property, used in any generated error messagespropertyValues
- the property array to check- Returns:
- a set representation of the values in
propertyValues
- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValues
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 nameprimaryCollection
- the first collection property's valuesecondaryName
- the second collection property's namesecondaryCollection
- 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 nameprimaryArray
- the first array property's valuesecondaryName
- the second array property's namesecondaryArray
- 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 nameprimaryCollection
- the collection property's valuesecondaryName
- the array property's namesecondaryArray
- 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 nameprimaryArray
- the array property's valuesecondaryName
- the collection property's namesecondaryCollection
- 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 messagespropertyValues
- the property collection to check- Throws:
com.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- ifpropertyValues
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 anInvalidPropertyValueException
.- Parameters:
type
- the record type to checkpropertyName
- name of the property containing the field namesfieldNames
- 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 anInvalidPropertyValueException
.- Parameters:
type
- the record type to checkpropertyName
- name of the property containing the field namesfieldNames
- 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 handlingspecifier
- 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.
-
-