Interface ClickHouseOption

All Superinterfaces:
Serializable
All Known Implementing Classes:
ClickHouseDefaultOption

public interface ClickHouseOption extends Serializable
This defines a configuration option. To put it in a nutshell, an option is composed of key, default value(which implies type of the value) and description.
  • Method Details

    • toKeyValuePairs

      static Map<String,String> toKeyValuePairs(String str)
      Converts given string to key value pairs.
      Parameters:
      str - string
      Returns:
      non-null key value pairs
    • fromString

      static <T extends Serializable> T fromString(String value, Class<T> clazz)
      Converts given string to a typed value.
      Type Parameters:
      T - type of the value
      Parameters:
      value - value in string format
      clazz - non-null class of the value
      Returns:
      non-null typed value
    • fromString

      static <T extends Serializable> T fromString(String value, T defaultValue)
      Converts given string to typed value. When value is null or blank, defaultValue will be returned.
      Type Parameters:
      T - type of the value
      Parameters:
      value - value in string format
      defaultValue - non-null default value
      Returns:
      non-null typed value
    • getDefaultValue

      Serializable getDefaultValue()
      Gets default value of the option.
      Returns:
      default value of the option
    • getDefaultValueFromEnvVar

      default Optional<String> getDefaultValueFromEnvVar()
      Gets trimmed default value from environment variable. By default the environment variable is named as getPrefix() + "_" + name() in upper case.
      Returns:
      trimmed default value defined in environment variable
    • getDefaultValueFromSysProp

      default Optional<String> getDefaultValueFromSysProp()
      Gets trimmed default value from system property. By default the system property is named as getPrefix() + "_" + name() in lower case.
      Returns:
      trimmed default value defined in system property
    • getDescription

      String getDescription()
      Gets description of the option.
      Returns:
      description of the option
    • getEffectiveDefaultValue

      default Serializable getEffectiveDefaultValue()
      Gets effective default value by considering default value defined in system property and environment variable. It's same as getDefaultValue() if no system property and environment variable defined.
      Returns:
      effective default value
    • getEffectiveValue

      default <T> T getEffectiveValue(T value)
      Gets effective value by considering default value defined in system property and environment variable. It's same as getDefaultValue() if the given value is null and no system property and environment variable defined.
      Type Parameters:
      T - type of the value
      Parameters:
      value - default value
      Returns:
      effective value
    • getKey

      String getKey()
      Gets key of the option.
      Returns:
      key of the option
    • getPrefix

      default String getPrefix()
      Gets prefix of environment variable and system property.
      Returns:
      prefix of environment variable and system property
    • getEnvironmentVariable

      default String getEnvironmentVariable()
      Gets environment variable for the option.
      Returns:
      environment variable
    • getSystemProperty

      default String getSystemProperty()
      Gets system property for the option.
      Returns:
      system property
    • getValueType

      Class<? extends Serializable> getValueType()
      Gets value type of the option.
      Returns:
      value type of the option, defaults to String
    • isSensitive

      boolean isSensitive()
      Checks whether the option is sensitive or not. A sensitive option should be used carefully and be masked in logging for security reason.
      Returns:
      true if the option is sensitive; false otherwise
    • name

      String name()
      Gets name of the option.
      Returns:
      name of the option