Class ConfigCondition
- java.lang.Object
-
- com.inductiveautomation.perspective.common.ConfigCondition
-
public class ConfigCondition extends java.lang.Object
Convenience class for ensuring that a json object structure has expected members in it.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfigCondition
ofObject(com.inductiveautomation.ignition.common.gson.JsonElement object)
ConfigCondition
optional(java.lang.String name, java.util.function.Predicate<com.inductiveautomation.ignition.common.gson.JsonElement> predicate, java.util.function.Function<com.inductiveautomation.ignition.common.gson.JsonElement,java.lang.String> errorMessage)
General purpose optional-check.ConfigCondition
optionalArray(java.lang.String name)
Checks to see if a member with the given name exists.ConfigCondition
optionalBoolean(java.lang.String name)
Checks to see if a member with the given name exists.<E extends java.lang.Enum>
ConfigConditionoptionalEnum(java.lang.String name, java.lang.Class<E> enumClass)
Case-sensitive enum comparison<E extends java.lang.Enum>
ConfigConditionoptionalEnum(java.lang.String name, java.lang.Class<E> enumClass, boolean ignoreCase)
ConfigCondition
optionalObject(java.lang.String name)
Checks to see if a member with the given name exists.ConfigCondition
optionalOneOf(java.lang.String name, JsonType... types)
Checks to see if a member with the given name exists.ConfigCondition
optionalString(java.lang.String name)
Checks to see if a member with the given name exists.ConfigCondition
requireNonBlankString(java.lang.String name)
Requires that the property at the given path is a string that is not blank.ConfigCondition
requireObject(java.lang.String name)
Requires that the property at the given path is an object.ConfigCondition
requireOneOf(java.lang.String name, JsonType... types)
Requires that the property at the given path is one of the providedJsonTypes
.ConfigCondition
requireString(java.lang.String name)
Requires that the property at the given path is a string.
-
-
-
Method Detail
-
ofObject
public static ConfigCondition ofObject(com.inductiveautomation.ignition.common.gson.JsonElement object) throws ConfigurationException
- Throws:
ConfigurationException
-
optionalOneOf
public ConfigCondition optionalOneOf(java.lang.String name, @Nonnull JsonType... types) throws ConfigurationException
Checks to see if a member with the given name exists. If it does, ensures that it is one of the providedJsonTypes
- Throws:
ConfigurationException
-
requireOneOf
public ConfigCondition requireOneOf(java.lang.String name, @Nonnull JsonType... types) throws ConfigurationException
Requires that the property at the given path is one of the providedJsonTypes
. Does not accept null, missing, or otherwise mis-typed.- Throws:
ConfigurationException
-
requireObject
public ConfigCondition requireObject(java.lang.String name) throws ConfigurationException
Requires that the property at the given path is an object. Does not accept null, missing, or otherwise mis-typed.- Throws:
ConfigurationException
-
requireString
public ConfigCondition requireString(java.lang.String name) throws ConfigurationException
Requires that the property at the given path is a string. Accepts empty string, but not null, missing, or otherwise mis-typed.- Throws:
ConfigurationException
-
requireNonBlankString
public ConfigCondition requireNonBlankString(java.lang.String name) throws ConfigurationException
Requires that the property at the given path is a string that is not blank. Accepts empty string, but not null, missing, or otherwis mis-typed.- Throws:
ConfigurationException
- See Also:
StringUtils.isNotBlank(CharSequence)
-
optionalEnum
public <E extends java.lang.Enum> ConfigCondition optionalEnum(java.lang.String name, java.lang.Class<E> enumClass) throws ConfigurationException
Case-sensitive enum comparison- Throws:
ConfigurationException
- See Also:
optionalEnum(String, Class, boolean)
-
optionalEnum
public <E extends java.lang.Enum> ConfigCondition optionalEnum(java.lang.String name, java.lang.Class<E> enumClass, boolean ignoreCase) throws ConfigurationException
- Throws:
ConfigurationException
-
optionalObject
public ConfigCondition optionalObject(java.lang.String name) throws ConfigurationException
Checks to see if a member with the given name exists. If it does, ensures that it is an object.- Throws:
ConfigurationException
-
optionalArray
public ConfigCondition optionalArray(java.lang.String name) throws ConfigurationException
Checks to see if a member with the given name exists. If it does, ensures that it is an array.- Throws:
ConfigurationException
-
optionalBoolean
public ConfigCondition optionalBoolean(java.lang.String name) throws ConfigurationException
Checks to see if a member with the given name exists. If it does, ensures that it is a boolean.- Throws:
ConfigurationException
-
optionalString
public ConfigCondition optionalString(java.lang.String name) throws ConfigurationException
Checks to see if a member with the given name exists. If it does, ensures that it is a string.- Throws:
ConfigurationException
-
optional
public ConfigCondition optional(java.lang.String name, java.util.function.Predicate<com.inductiveautomation.ignition.common.gson.JsonElement> predicate, java.util.function.Function<com.inductiveautomation.ignition.common.gson.JsonElement,java.lang.String> errorMessage) throws ConfigurationException
General purpose optional-check. If the object at the given name is missing, this is OK. But if the object is present, it must pass the predicate.- Throws:
ConfigurationException
-
-