Class ConfigCondition
java.lang.Object
com.inductiveautomation.perspective.common.ConfigCondition
Convenience class for ensuring that a json object structure has expected members in it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigCondition
ofObject
(com.inductiveautomation.ignition.common.gson.JsonElement object) optional
(String name, Predicate<com.inductiveautomation.ignition.common.gson.JsonElement> predicate, Function<com.inductiveautomation.ignition.common.gson.JsonElement, String> errorMessage) General purpose optional-check.optionalArray
(String name) Checks to see if a member with the given name exists.optionalBoolean
(String name) Checks to see if a member with the given name exists.<E extends Enum>
ConfigConditionoptionalEnum
(String name, Class<E> enumClass) Case-sensitive enum comparison<E extends Enum>
ConfigConditionoptionalEnum
(String name, Class<E> enumClass, boolean ignoreCase) optionalObject
(String name) Checks to see if a member with the given name exists.optionalOneOf
(String name, JsonType... types) Checks to see if a member with the given name exists.optionalString
(String name) Checks to see if a member with the given name exists.requireNonBlankString
(String name) Requires that the property at the given path is a string that is not blank.requireObject
(String name) Requires that the property at the given path is an object.requireOneOf
(String name, JsonType... types) Requires that the property at the given path is one of the providedJsonTypes
.requireString
(String name) Requires that the property at the given path is a string.
-
Method Details
-
ofObject
public static ConfigCondition ofObject(com.inductiveautomation.ignition.common.gson.JsonElement object) throws ConfigurationException - Throws:
ConfigurationException
-
optionalOneOf
public ConfigCondition optionalOneOf(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(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
Requires that the property at the given path is an object. Does not accept null, missing, or otherwise mis-typed.- Throws:
ConfigurationException
-
requireString
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
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 Enum> ConfigCondition optionalEnum(String name, Class<E> enumClass) throws ConfigurationException Case-sensitive enum comparison- Throws:
ConfigurationException
- See Also:
-
optionalEnum
public <E extends Enum> ConfigCondition optionalEnum(String name, Class<E> enumClass, boolean ignoreCase) throws ConfigurationException - Throws:
ConfigurationException
-
optionalObject
Checks to see if a member with the given name exists. If it does, ensures that it is an object.- Throws:
ConfigurationException
-
optionalArray
Checks to see if a member with the given name exists. If it does, ensures that it is an array.- Throws:
ConfigurationException
-
optionalBoolean
Checks to see if a member with the given name exists. If it does, ensures that it is a boolean.- Throws:
ConfigurationException
-
optionalString
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(String name, Predicate<com.inductiveautomation.ignition.common.gson.JsonElement> predicate, Function<com.inductiveautomation.ignition.common.gson.JsonElement, String> errorMessage) throws ConfigurationExceptionGeneral 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
-