Class YMLUtil
java.lang.Object
com.illumon.iris.db.v2.routing.impl.yaml.YMLUtil
Functions to help
DataRoutingServiceYmlImpl parse yml files.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvenience method: cast the value of key to a map.static BooleangetOptionalBoolean(Map<?, Object> yml, String tag, String context) Convenience: cast the value of key to a Boolean, or throw aDataRoutingConfigurationException.static intgetOptionalIntWithDefault(Map<?, Object> yml, String tag, int defaultValue, String context) Convenience: cast the value of key to an int, or throw aDataRoutingConfigurationException.static StringgetOptionalString(Map<?, Object> yml, String tag, String context) Convenience: cast the value of key to a String, or throw aDataRoutingConfigurationException.
-
Constructor Details
-
YMLUtil
public YMLUtil()
-
-
Method Details
-
getOptionalString
@Nullable public static String getOptionalString(@NotNull Map<?, Object> yml, @NotNull String tag, @NotNull String context) Convenience: cast the value of key to a String, or throw aDataRoutingConfigurationException. Also callsreplaceTokens(Object)on the value.- Parameters:
yml- a yml maptag- the key to getcontext- string for context in the possible exception- Returns:
- a (possibly null) String value for the tag
-
getOptionalIntWithDefault
public static int getOptionalIntWithDefault(@NotNull Map<?, Object> yml, @NotNull String tag, int defaultValue, @NotNull String context) Convenience: cast the value of key to an int, or throw aDataRoutingConfigurationException.- Parameters:
yml- a yml maptag- the key to getdefaultValue- use this value if the tag is unsetcontext- string for context in the possible exception- Returns:
- an int value for the tag
-
getOptionalBoolean
@Nullable public static Boolean getOptionalBoolean(@NotNull Map<?, Object> yml, @NotNull String tag, @NotNull String context) Convenience: cast the value of key to a Boolean, or throw aDataRoutingConfigurationException.- Parameters:
yml- a yml maptag- the key to getcontext- optional string for context in the possible exception- Returns:
- a (possibly null) Boolean value for the tag
-
getMap
@NotNull public static Map<Object,Object> getMap(@NotNull Map<?, Object> yml, @NotNull String tag, boolean required, @NotNull String context) Convenience method: cast the value of key to a map. Throw aDataRoutingConfigurationExceptionif the value is the wrong type.- Parameters:
yml- a yml maptag- the key to getrequired- if true, throw aDataRoutingConfigurationExceptionif the value is missingcontext- string for context in the possible exception- Returns:
- a valid
Map<Object, Object>, possibly empty. - Throws:
DataRoutingConfigurationException- if required is true and the tag isn't present
-