java.lang.Object
com.illumon.iris.db.v2.routing.impl.yaml.YMLUtil

public class YMLUtil extends Object
Functions to help DataRoutingServiceYmlImpl parse yml files.
  • 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 a DataRoutingConfigurationException. Also calls replaceTokens(Object) on the value.
      Parameters:
      yml - a yml map
      tag - the key to get
      context - 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 a DataRoutingConfigurationException.
      Parameters:
      yml - a yml map
      tag - the key to get
      defaultValue - use this value if the tag is unset
      context - 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 a DataRoutingConfigurationException.
      Parameters:
      yml - a yml map
      tag - the key to get
      context - 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 a DataRoutingConfigurationException if the value is the wrong type.
      Parameters:
      yml - a yml map
      tag - the key to get
      required - if true, throw a DataRoutingConfigurationException if the value is missing
      context - 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