Interface Configuration

All Known Subinterfaces:
JdbcConfiguration

@Immutable public interface Configuration
An immutable representation of a Debezium configuration. A Configuration instance can be obtained from Properties or loaded from a file, stream, reader, URL, or classpath resource. They can also be built by first creating a builder and then using that builder to populate and return the immutable Configuration instance.

A Configuration object is basically a decorator around a Properties object. It has methods to get and convert individual property values to numeric, boolean and String types, optionally using a default value if the given property value does not exist. However, it is immutable, so it does not have any methods to set property values, allowing it to be passed around and reused without concern that other components might change the underlying property values.

Author:
Randall Hauch
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    A builder of Configuration objects.
    static interface 
    The basic interface for configuration builders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
     
    static final Pattern
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default Map<String,String>
    Get a copy of these configuration properties as a Properties object.
    default Map<String,String>
    asMap(Field.Set fields)
    Get a copy of these configuration properties with defaults as a Map.
    default Properties
    Get a copy of these configuration properties as a Properties object.
    default Properties
    Get a copy of these configuration properties as a Properties object.
    Create a new configuration builder that starts with a copy of the supplied configuration.
    Create a new configuration builder.
    Obtain an editor for a copy of this configuration.
    Obtain an empty configuration.
    filter(Predicate<? super String> matcher)
    Return a new Configuration that contains only the subset of keys that satisfy the given predicate.
    default <T> void
    Call the supplied function for each of the fields.
    default <T> void
    forEachMatchingFieldName(String regex, int groupNumber, BiFunction<String,String,T> groupExtractor, BiConsumer<String,T> function)
    For all fields whose names match the given regular expression, extract a value from the specified group in the regular expression and call the supplied function.
    default void
    Apply the given function to all fields whose names match the given regular expression.
    default <T> void
    forEachMatchingFieldName(Pattern regex, int groupNumber, BiFunction<String,String,T> groupExtractor, BiConsumer<String,T> function)
    For all fields whose names match the given regular expression, extract a value from the specified group in the regular expression and call the supplied function.
    default void
    Apply the given function to all fields whose names match the given regular expression.
    default <T> void
    For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
    default <T> void
    forEachMatchingFieldNameWithString(String regex, int groupNumber, BiConsumer<String,String> function)
    For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
    default <T> void
    For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
    default <T> void
    forEachMatchingFieldNameWithString(Pattern regex, int groupNumber, BiConsumer<String,String> function)
    For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
    from(Map<String,?> properties)
    Obtain a configuration instance by copying the supplied map of string keys and object values.
    static <T> Configuration
    from(Map<String,T> properties, Function<T,String> conversion)
    Obtain a configuration instance by copying the supplied map of string keys and object values.
    from(Properties properties)
    Obtain a configuration instance by copying the supplied Properties object.
    Create a Configuration object that is populated by system properties, per withSystemProperties(String).
    default boolean
    Get the boolean value associated with the given field when that field has a default value.
    default boolean
    getBoolean(Field field, boolean defaultValue)
    Get the boolean value associated with the given field, returning the field's default value if there is no such key-value pair.
    default Boolean
    getBoolean(Field field, BooleanSupplier defaultValueSupplier)
    Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default Boolean
    Get the boolean value associated with the given key.
    default boolean
    getBoolean(String key, boolean defaultValue)
    Get the boolean value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as a boolean value.
    default Boolean
    getBoolean(String key, BooleanSupplier defaultValueSupplier)
    Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default Duration
    Gets the duration value associated with the given key.
    default <T> T
    getInstance(Field field, Class<T> type)
    Get an instance of the class given by the value in the configuration associated with the given field.
    default <T> T
    getInstance(Field field, Class<T> clazz, Configuration configuration)
    Get an instance of the class given by the value in the configuration associated with the given field.
    default <T> T
    getInstance(Field field, Class<T> clazz, Properties props)
    Get an instance of the class given by the value in the configuration associated with the given field.
    default <T> T
    getInstance(String key, Class<T> type)
    Get an instance of the class given by the value in the configuration associated with the given key.
    default <T> T
    getInstance(String key, Class<T> clazz, Configuration configuration)
    Get an instance of the class given by the value in the configuration associated with the given key.
    default int
    Get the integer value associated with the given field, returning the field's default value if there is no such key-value pair.
    default int
    getInteger(Field field, int defaultValue)
    Get the integer value associated with the given field, returning the field's default value if there is no such key-value pair.
    default Integer
    getInteger(Field field, IntSupplier defaultValueSupplier)
    Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default Integer
    Get the integer value associated with the given key.
    default int
    getInteger(String key, int defaultValue)
    Get the integer value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as an integer.
    default Integer
    getInteger(String key, IntSupplier defaultValueSupplier)
    Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default long
    getLong(Field field)
    Get the long value associated with the given field, returning the field's default value if there is no such key-value pair.
    default long
    getLong(Field field, long defaultValue)
    Get the long value associated with the given field, returning the field's default value if there is no such key-value pair.
    default Long
    getLong(Field field, LongSupplier defaultValueSupplier)
    Get the long value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default Long
    Get the long value associated with the given key.
    default long
    getLong(String key, long defaultValue)
    Get the long value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as a long.
    default Long
    getLong(String key, LongSupplier defaultValueSupplier)
    Get the long value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default Number
    Get the numeric value associated with the given field, returning the field's default value if there is no such key-value pair.
    default Number
    getNumber(String key, Supplier<Number> defaultValueSupplier)
    Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    default String
    Get the string value associated with the given field, returning the field's default value if there is no such key-value pair in this configuration.
    default String
    getString(Field field, String defaultValue)
    Get the string value associated with the given field, returning the field's default value if there is no such key-value pair in this configuration.
    default String
    getString(Field field, Supplier<String> defaultValueSupplier)
    Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
    Get the string value associated with the given key.
    default String
    getString(String key, String defaultValue)
    Get the string value associated with the given key, returning the default value if there is no such key-value pair.
    default String
    getString(String key, Supplier<String> defaultValueSupplier)
    Get the string value associated with the given key, returning the default value if there is no such key-value pair.
    default List<String>
    getStrings(Field field, String regex)
    Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values.
    default List<String>
    getStrings(String key, String regex)
    Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values.
    default List<String>
    Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values.
    default boolean
    hasKey(Field field)
    Determine whether this configuration contains a key-value pair associated with the given field and the value is non-null.
    default boolean
    Determine whether this configuration contains a key-value pair with the given key and the value is non-null
    default boolean
    Determine if this configuration is empty and has no properties.
    Get the set of keys in this configuration.
    load(File file)
    Obtain a configuration instance by loading the Properties from the supplied file.
    load(InputStream stream)
    Obtain a configuration instance by loading the Properties from the supplied stream.
    load(Reader reader)
    Obtain a configuration instance by loading the Properties from the supplied reader.
    load(String path, Class<?> clazz)
    Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
    load(String path, ClassLoader classLoader)
    Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
    load(String path, ClassLoader classLoader, Consumer<String> logger)
    Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
    load(URL url)
    Obtain a configuration instance by loading the Properties from the supplied URL.
    Return a new Configuration that contains only the subset of keys that satisfy the given predicate.
    mapped(BiFunction<? super String,? super String,String> mapper)
    Return a new Configuration that contains the mapped values.
    merge(Configuration... configs)
    Return a new Configuration that merges several Configurations into one.
    subset(String prefix, boolean removePrefix)
    Return a new Configuration that contains only the subset of keys that match the given prefix.
    default Map<String,org.apache.kafka.common.config.ConfigValue>
    Validate the supplied fields in this configuration.
    default boolean
    Validate the supplied fields in this configuration.
    default boolean
    Validate the supplied fields in this configuration.
    withMasked(String keyRegex)
    Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that match the specified pattern.
    withMasked(Pattern keyRegex)
    Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that match the specified pattern.
    Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that end in "password".
    Return a new Configuration that contains all of the same fields as this configuration, except with all variables in the fields replaced with values from the supplied function.
    Return a copy of this configuration except where acceptable system properties are used to overwrite properties copied from this configuration.
    withSystemProperties(Function<String,String> propertyNameConverter)
    Return a copy of this configuration except where acceptable system properties are used to overwrite properties copied from this configuration.
  • Field Details

    • CONFIGURATION_LOGGER

      static final org.slf4j.Logger CONFIGURATION_LOGGER
    • PASSWORD_PATTERN

      static final Pattern PASSWORD_PATTERN
  • Method Details

    • create

      static Configuration.Builder create()
      Create a new configuration builder.
      Returns:
      the configuration builder
    • copy

      static Configuration.Builder copy(Configuration config)
      Create a new configuration builder that starts with a copy of the supplied configuration.
      Parameters:
      config - the configuration to copy; may be null
      Returns:
      the configuration builder
    • fromSystemProperties

      static Configuration fromSystemProperties(String prefix)
      Create a Configuration object that is populated by system properties, per withSystemProperties(String).
      Parameters:
      prefix - the required prefix for the system properties; may not be null but may be empty
      Returns:
      the configuration
    • empty

      static Configuration empty()
      Obtain an empty configuration.
      Returns:
      an empty configuration; never null
    • from

      static Configuration from(Properties properties)
      Obtain a configuration instance by copying the supplied Properties object. The supplied Properties object is copied so that the resulting Configuration cannot be modified.
      Parameters:
      properties - the properties; may be null or empty
      Returns:
      the configuration; never null
    • from

      static Configuration from(Map<String,?> properties)
      Obtain a configuration instance by copying the supplied map of string keys and object values. The entries within the map are copied so that the resulting Configuration cannot be modified.
      Parameters:
      properties - the properties; may be null or empty
      Returns:
      the configuration; never null
    • from

      static <T> Configuration from(Map<String,T> properties, Function<T,String> conversion)
      Obtain a configuration instance by copying the supplied map of string keys and object values. The entries within the map are copied so that the resulting Configuration cannot be modified.
      Parameters:
      properties - the properties; may be null or empty
      conversion - the function that converts the supplied values into strings, or returns null if the value is to be excluded
      Returns:
      the configuration; never null
    • load

      static Configuration load(URL url) throws IOException
      Obtain a configuration instance by loading the Properties from the supplied URL.
      Parameters:
      url - the URL to the stream containing the configuration properties; may not be null
      Returns:
      the configuration; never null
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(File file) throws IOException
      Obtain a configuration instance by loading the Properties from the supplied file.
      Parameters:
      file - the file containing the configuration properties; may not be null
      Returns:
      the configuration; never null
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(InputStream stream) throws IOException
      Obtain a configuration instance by loading the Properties from the supplied stream.
      Parameters:
      stream - the stream containing the properties; may not be null
      Returns:
      the configuration; never null
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(Reader reader) throws IOException
      Obtain a configuration instance by loading the Properties from the supplied reader.
      Parameters:
      reader - the reader containing the properties; may not be null
      Returns:
      the configuration; never null
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(String path, Class<?> clazz) throws IOException
      Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
      Parameters:
      path - the path to the file containing the configuration properties; may not be null
      clazz - the class whose classpath is to be used to find the file; may be null
      Returns:
      the configuration; never null but possibly empty
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(String path, ClassLoader classLoader) throws IOException
      Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
      Parameters:
      path - the path to the file containing the configuration properties; may not be null
      classLoader - the class loader to use; may be null
      Returns:
      the configuration; never null but possibly empty
      Throws:
      IOException - if there is an error reading the stream
    • load

      static Configuration load(String path, ClassLoader classLoader, Consumer<String> logger) throws IOException
      Obtain a configuration instance by loading the Properties from a file on the file system or classpath given by the supplied path.
      Parameters:
      path - the path to the file containing the configuration properties; may not be null
      classLoader - the class loader to use; may be null
      logger - the function that will be called with status updates; may be null
      Returns:
      the configuration; never null but possibly empty
      Throws:
      IOException - if there is an error reading the stream
    • edit

      default Configuration.Builder edit()
      Obtain an editor for a copy of this configuration.
      Returns:
      a builder that is populated with this configuration's key-value pairs; never null
    • hasKey

      default boolean hasKey(String key)
      Determine whether this configuration contains a key-value pair with the given key and the value is non-null
      Parameters:
      key - the key
      Returns:
      true if the configuration contains the key, or false otherwise
    • hasKey

      default boolean hasKey(Field field)
      Determine whether this configuration contains a key-value pair associated with the given field and the value is non-null.
      Parameters:
      field - the field; may not be null
      Returns:
      true if the configuration contains the key, or false otherwise
    • keys

      Set<String> keys()
      Get the set of keys in this configuration.
      Returns:
      the set of keys; never null but possibly empty
    • getString

      String getString(String key)
      Get the string value associated with the given key.
      Parameters:
      key - the key for the configuration property
      Returns:
      the value, or null if the key is null or there is no such key-value pair in the configuration
    • getString

      default String getString(String key, String defaultValue)
      Get the string value associated with the given key, returning the default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValue - the value that should be returned by default if there is no such key-value pair in the configuration; may be null
      Returns:
      the configuration value, or the defaultValue if there is no such key-value pair in the configuration
    • getString

      default String getString(String key, Supplier<String> defaultValueSupplier)
      Get the string value associated with the given key, returning the default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValueSupplier - the supplier of value that should be returned by default if there is no such key-value pair in the configuration; may be null and may return null
      Returns:
      the configuration value, or the defaultValue if there is no such key-value pair in the configuration
    • getString

      default String getString(Field field)
      Get the string value associated with the given field, returning the field's default value if there is no such key-value pair in this configuration.
      Parameters:
      field - the field; may not be null
      Returns:
      the configuration's value for the field, or the field's default value if there is no such key-value pair in the configuration
    • getString

      default String getString(Field field, String defaultValue)
      Get the string value associated with the given field, returning the field's default value if there is no such key-value pair in this configuration.
      Parameters:
      field - the field; may not be null
      defaultValue - the default value
      Returns:
      the configuration's value for the field, or the field's default value if there is no such key-value pair in the configuration
    • getStrings

      default List<String> getStrings(Field field, String regex)
      Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values.
      Parameters:
      field - the field; may not be null
      regex - the delimiting regular expression
      Returns:
      the list of string values; null only if there is no such key-value pair in the configuration
      See Also:
    • getStrings

      default List<String> getStrings(String key, String regex)
      Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values.
      Parameters:
      key - the key for the configuration property
      regex - the delimiting regular expression
      Returns:
      the list of string values; null only if there is no such key-value pair in the configuration
      See Also:
    • getTrimmedStrings

      default List<String> getTrimmedStrings(Field field, String regex)
      Get the string value(s) associated with the given key, where the supplied regular expression is used to parse the single string value into multiple values. In addition, all values will be trimmed.
      Parameters:
      field - the field for the configuration property
      regex - the delimiting regular expression
      Returns:
      the list of string values; null only if there is no such key-value pair in the configuration
      See Also:
    • getInteger

      default Integer getInteger(String key)
      Get the integer value associated with the given key.
      Parameters:
      key - the key for the configuration property
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as an integer
    • getLong

      default Long getLong(String key)
      Get the long value associated with the given key.
      Parameters:
      key - the key for the configuration property
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as an integer
    • getBoolean

      default Boolean getBoolean(String key)
      Get the boolean value associated with the given key.
      Parameters:
      key - the key for the configuration property
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as a boolean value
    • getInteger

      default int getInteger(String key, int defaultValue)
      Get the integer value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as an integer.
      Parameters:
      key - the key for the configuration property
      defaultValue - the default value
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as an integer
    • getLong

      default long getLong(String key, long defaultValue)
      Get the long value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as a long.
      Parameters:
      key - the key for the configuration property
      defaultValue - the default value
      Returns:
      the long value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as a long
    • getBoolean

      default boolean getBoolean(String key, boolean defaultValue)
      Get the boolean value associated with the given key, returning the default value if there is no such key-value pair or if the value could not be parsed as a boolean value.
      Parameters:
      key - the key for the configuration property
      defaultValue - the default value
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration, or the value could not be parsed as a boolean value
    • getNumber

      default Number getNumber(String key, Supplier<Number> defaultValueSupplier)
      Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as an integer
    • getInteger

      default Integer getInteger(String key, IntSupplier defaultValueSupplier)
      Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as an integer
    • getLong

      default Long getLong(String key, LongSupplier defaultValueSupplier)
      Get the long value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the long value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as a long
    • getBoolean

      default Boolean getBoolean(String key, BooleanSupplier defaultValueSupplier)
      Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      key - the key for the configuration property
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
    • getNumber

      default Number getNumber(Field field)
      Get the numeric value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as an integer value
      Throws:
      NumberFormatException - if there is no name-value pair and the field has no default value
    • getInteger

      default int getInteger(Field field)
      Get the integer value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as an integer value
      Throws:
      NumberFormatException - if there is no name-value pair and the field has no default value
    • getLong

      default long getLong(Field field)
      Get the long value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as a long value
      Throws:
      NumberFormatException - if there is no name-value pair and the field has no default value
    • getBoolean

      default boolean getBoolean(Field field)
      Get the boolean value associated with the given field when that field has a default value. If the configuration does not have a name-value pair with the same name as the field, then the field's default value.
      Parameters:
      field - the field
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
      Throws:
      NumberFormatException - if there is no name-value pair and the field has no default value
    • getInteger

      default int getInteger(Field field, int defaultValue)
      Get the integer value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValue - the default value
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as an integer value
    • getLong

      default long getLong(Field field, long defaultValue)
      Get the long value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValue - the default value
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as a long value
    • getBoolean

      default boolean getBoolean(Field field, boolean defaultValue)
      Get the boolean value associated with the given field, returning the field's default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValue - the default value
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration and there is no default value in the field or the default value could not be parsed as a long, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
    • getInteger

      default Integer getInteger(Field field, IntSupplier defaultValueSupplier)
      Get the integer value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the integer value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as an integer
    • getLong

      default Long getLong(Field field, LongSupplier defaultValueSupplier)
      Get the long value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the long value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as a long
    • getBoolean

      default Boolean getBoolean(Field field, BooleanSupplier defaultValueSupplier)
      Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValueSupplier - the supplier for the default value; may be null
      Returns:
      the boolean value, or null if the key is null, there is no such key-value pair in the configuration, the defaultValueSupplier reference is null, or there is a key-value pair in the configuration but the value could not be parsed as a boolean value
    • getString

      default String getString(Field field, Supplier<String> defaultValueSupplier)
      Get the boolean value associated with the given key, using the given supplier to obtain a default value if there is no such key-value pair.
      Parameters:
      field - the field
      defaultValueSupplier - the supplier of value that should be returned by default if there is no such key-value pair in the configuration; may be null and may return null
      Returns:
      the configuration value, or the defaultValue if there is no such key-value pair in the configuration
    • getDuration

      default Duration getDuration(Field field, TemporalUnit unit)
      Gets the duration value associated with the given key.
      Parameters:
      field - the field
      unit - the temporal unit of the duration value
      Returns:
      the duration value associated with the given key
    • getInstance

      default <T> T getInstance(String key, Class<T> type)
      Get an instance of the class given by the value in the configuration associated with the given key.
      Parameters:
      key - the key for the configuration property
      type - the Class of which the resulting object is expected to be an instance of; may not be null
      Returns:
      the new instance, or null if there is no such key-value pair in the configuration or if there is a key-value configuration but the value could not be converted to an existing class with a zero-argument constructor
    • getInstance

      default <T> T getInstance(String key, Class<T> clazz, Configuration configuration)
      Get an instance of the class given by the value in the configuration associated with the given key. The instance is created using Instance(Configuration) constructor.
      Parameters:
      key - the key for the configuration property
      clazz - the Class of which the resulting object is expected to be an instance of; may not be null
      configuration - Configuration object that is passed as a parameter to the constructor
      Returns:
      the new instance, or null if there is no such key-value pair in the configuration or if there is a key-value configuration but the value could not be converted to an existing class with a zero-argument constructor
    • getInstance

      default <T> T getInstance(Field field, Class<T> type)
      Get an instance of the class given by the value in the configuration associated with the given field.
      Parameters:
      field - the field for the configuration property
      type - the Class of which the resulting object is expected to be an instance of; may not be null
      Returns:
      the new instance, or null if there is no such key-value pair in the configuration or if there is a key-value configuration but the value could not be converted to an existing class with a zero-argument constructor
    • getInstance

      default <T> T getInstance(Field field, Class<T> clazz, Configuration configuration)
      Get an instance of the class given by the value in the configuration associated with the given field. The instance is created using Instance(Configuration) constructor.
      Parameters:
      field - the field for the configuration property
      clazz - the Class of which the resulting object is expected to be an instance of; may not be null
      configuration - the Configuration object that is passed as a parameter to the constructor
      Returns:
      the new instance, or null if there is no such key-value pair in the configuration or if there is a key-value configuration but the value could not be converted to an existing class with a zero-argument constructor
    • getInstance

      default <T> T getInstance(Field field, Class<T> clazz, Properties props)
      Get an instance of the class given by the value in the configuration associated with the given field. The instance is created using Instance(Configuration) constructor.
      Parameters:
      field - the field for the configuration property
      clazz - the Class of which the resulting object is expected to be an instance of; may not be null
      props - the Properties object that is passed as a parameter to the constructor
      Returns:
      the new instance, or null if there is no such key-value pair in the configuration or if there is a key-value configuration but the value could not be converted to an existing class with a zero-argument constructor
    • subset

      default Configuration subset(String prefix, boolean removePrefix)
      Return a new Configuration that contains only the subset of keys that match the given prefix. If desired, the keys in the resulting Configuration will have the prefix (plus any terminating "." character if needed) removed.

      This method returns this Configuration instance if the supplied prefix is null or empty.

      Parameters:
      prefix - the prefix
      removePrefix - true if the prefix (and any subsequent "." character) should be removed from the keys in the resulting Configuration, or false if the keys in this Configuration should be used as-is in the resulting Configuration
      Returns:
      the subset of this Configuration; never null
    • merge

      default Configuration merge(Configuration... configs)
      Return a new Configuration that merges several Configurations into one.

      This method returns this Configuration instance if the supplied configs is null or empty.

      Parameters:
      configs - Configurations to be merged
      Returns:
      the subset of this Configuration; never null
    • map

      default Configuration map(Function<String,String> mapper)
      Return a new Configuration that contains only the subset of keys that satisfy the given predicate.
      Parameters:
      mapper - that function that transforms keys
      Returns:
      the subset Configuration; never null
    • filter

      default Configuration filter(Predicate<? super String> matcher)
      Return a new Configuration that contains only the subset of keys that satisfy the given predicate.
      Parameters:
      matcher - the function that determines whether a key should be included in the subset
      Returns:
      the subset Configuration; never null
    • mapped

      default Configuration mapped(BiFunction<? super String,? super String,String> mapper)
      Return a new Configuration that contains the mapped values.
      Parameters:
      mapper - the function that takes a key and value and returns the new mapped value
      Returns:
      the Configuration with mapped values; never null
    • withReplacedVariables

      default Configuration withReplacedVariables(Function<String,String> valuesByVariableName)
      Return a new Configuration that contains all of the same fields as this configuration, except with all variables in the fields replaced with values from the supplied function. Variables found in fields will be left as-is if the supplied function returns no value for the variable name(s).

      Variables may appear anywhere within a field value, and multiple variables can be used within the same field. Variables take the form:

          variable := '${' variableNames [ ':' defaultValue ] '}'
          variableNames := variableName [ ',' variableNames ]
          variableName := // any characters except ',' and ':' and '}'
          defaultValue := // any characters except '}'
       
      and examples of variables include:
      • ${var1}
      • ${var1:defaultValue}
      • ${var1,var2}
      • ${var1,var2:defaultValue}
      The variableName literal is the name used to look up a the property.

      This syntax supports multiple variables. The logic will process the variables from let to right, until an existing property is found. And at that point, it will stop and will not attempt to find values for the other variables.

      Parameters:
      valuesByVariableName - the function that returns a variable value for a variable name; may not be null but may return null if the variable name is not known
      Returns:
      the Configuration with masked values for matching keys; never null
    • withMaskedPasswords

      default Configuration withMaskedPasswords()
      Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that end in "password".
      Returns:
      the Configuration with masked values for matching keys; never null
    • withMasked

      default Configuration withMasked(String keyRegex)
      Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that match the specified pattern.
      Parameters:
      keyRegex - the regular expression to match against the keys
      Returns:
      the Configuration with masked values for matching keys; never null
    • withMasked

      default Configuration withMasked(Pattern keyRegex)
      Return a new Configuration that contains all of the same fields as this configuration, except with masked values for all keys that match the specified pattern.
      Parameters:
      keyRegex - the regular expression to match against the keys
      Returns:
      the Configuration with masked values for matching keys; never null
    • isEmpty

      default boolean isEmpty()
      Determine if this configuration is empty and has no properties.
      Returns:
      true if empty, or false otherwise
    • asProperties

      default Properties asProperties()
      Get a copy of these configuration properties as a Properties object.
      Returns:
      the properties object; never null
    • asProperties

      default Properties asProperties(Field.Set fields)
      Get a copy of these configuration properties as a Properties object.
      Parameters:
      fields - the fields defining the defaults; may be null
      Returns:
      the properties object; never null
    • asMap

      default Map<String,String> asMap()
      Get a copy of these configuration properties as a Properties object.
      Returns:
      the properties object; never null
    • asMap

      default Map<String,String> asMap(Field.Set fields)
      Get a copy of these configuration properties with defaults as a Map.
      Parameters:
      fields - the fields defining the defaults; may be null
      Returns:
      the properties object; never null
    • withSystemProperties

      default Configuration withSystemProperties(String prefix)
      Return a copy of this configuration except where acceptable system properties are used to overwrite properties copied from this configuration. All system properties whose name has the given prefix are added, where the prefix is removed from the system property name, it is converted to lower case, and each underscore character ('_') are replaced with a period ('.').
      Parameters:
      prefix - the required prefix for the system properties
      Returns:
      the resulting properties converted from the system properties; never null, but possibly empty
    • withSystemProperties

      default Configuration withSystemProperties(Function<String,String> propertyNameConverter)
      Return a copy of this configuration except where acceptable system properties are used to overwrite properties copied from this configuration. Each of the system properties is examined and passed to the supplied function; if the result of the function is a non-null string, then a property with that string as the name and the system property value are added to the returned configuration.
      Parameters:
      propertyNameConverter - the function that will convert the name of each system property to an applicable property name (or null if the system property name does not apply); may not be null
      Returns:
      the resulting properties filtered from the input properties; never null, but possibly empty
    • validate

      default boolean validate(Iterable<Field> fields, Field.ValidationOutput problems)
      Validate the supplied fields in this configuration. Extra fields not described by the supplied fields parameter are not validated.
      Parameters:
      fields - the fields
      problems - the consumer to be called with each problem; never null
      Returns:
      true if the value is considered valid, or false if it is not valid
    • validateAndRecord

      default boolean validateAndRecord(Iterable<Field> fields, Consumer<String> problems)
      Validate the supplied fields in this configuration. Extra fields not described by the supplied fields parameter are not validated.
      Parameters:
      fields - the fields
      problems - the consumer to be called with each problem; never null
      Returns:
      true if the value is considered valid, or false if it is not valid
    • validate

      default Map<String,org.apache.kafka.common.config.ConfigValue> validate(Field.Set fields)
      Validate the supplied fields in this configuration. Extra fields not described by the supplied fields parameter are not validated.
      Parameters:
      fields - the fields
      Returns:
      the ConfigValue for each of the fields; never null
    • forEachMatchingFieldName

      default void forEachMatchingFieldName(String regex, BiConsumer<String,String> function)
      Apply the given function to all fields whose names match the given regular expression.
      Parameters:
      regex - the regular expression string; may not be null
      function - the consumer that takes the name and value of matching fields; may not be null
    • forEachMatchingFieldName

      default void forEachMatchingFieldName(Pattern regex, BiConsumer<String,String> function)
      Apply the given function to all fields whose names match the given regular expression.
      Parameters:
      regex - the regular expression string; may not be null
      function - the consumer that takes the name and value of matching fields; may not be null
    • forEachMatchingFieldNameWithInteger

      default <T> void forEachMatchingFieldNameWithInteger(String regex, BiConsumer<String,Integer> function)
      For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      function - the consumer that takes the value of matching field and the integer extracted from the field name; may not be null
    • forEachMatchingFieldNameWithInteger

      default <T> void forEachMatchingFieldNameWithInteger(String regex, int groupNumber, BiConsumer<String,Integer> function)
      For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the integer to be extracted; must be positive
      function - the consumer that takes the value of matching field and the integer extracted from the field name; may not be null
    • forEachMatchingFieldNameWithInteger

      default <T> void forEachMatchingFieldNameWithInteger(Pattern regex, int groupNumber, BiConsumer<String,Integer> function)
      For all fields whose names match the given regular expression, extract an integer from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the integer to be extracted; must be positive
      function - the consumer that takes the value of matching field and the integer extracted from the field name; may not be null
    • forEachMatchingFieldNameWithBoolean

      default <T> void forEachMatchingFieldNameWithBoolean(String regex, BiConsumer<String,Boolean> function)
      For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      function - the consumer that takes the value of matching field and the boolean extracted from the field name; may not be null
    • forEachMatchingFieldNameWithBoolean

      default <T> void forEachMatchingFieldNameWithBoolean(String regex, int groupNumber, BiConsumer<String,Boolean> function)
      For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the boolean to be extracted; must be positive
      function - the consumer that takes the value of matching field and the boolean extracted from the field name; may not be null
    • forEachMatchingFieldNameWithBoolean

      default <T> void forEachMatchingFieldNameWithBoolean(Pattern regex, int groupNumber, BiConsumer<String,Boolean> function)
      For all fields whose names match the given regular expression, extract a boolean value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the boolean to be extracted; must be positive
      function - the consumer that takes the value of matching field and the boolean extracted from the field name; may not be null
    • forEachMatchingFieldNameWithString

      default <T> void forEachMatchingFieldNameWithString(String regex, BiConsumer<String,String> function)
      For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      function - the consumer that takes the value of matching field and the string value extracted from the field name; may not be null
    • forEachMatchingFieldNameWithString

      default <T> void forEachMatchingFieldNameWithString(String regex, int groupNumber, BiConsumer<String,String> function)
      For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the string value to be extracted; must be positive
      function - the consumer that takes the value of matching field and the string value extracted from the field name; may not be null
    • forEachMatchingFieldNameWithString

      default <T> void forEachMatchingFieldNameWithString(Pattern regex, int groupNumber, BiConsumer<String,String> function)
      For all fields whose names match the given regular expression, extract a string value from the first group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the string value to be extracted; must be positive
      function - the consumer that takes the value of matching field and the string value extracted from the field name; may not be null
    • forEachMatchingFieldName

      default <T> void forEachMatchingFieldName(String regex, int groupNumber, BiFunction<String,String,T> groupExtractor, BiConsumer<String,T> function)
      For all fields whose names match the given regular expression, extract a value from the specified group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the string value to be extracted; must be positive
      groupExtractor - the function that extracts the value from the group
      function - the consumer that takes the value of matching field and the value extracted from the field name; may not be null
    • forEachMatchingFieldName

      default <T> void forEachMatchingFieldName(Pattern regex, int groupNumber, BiFunction<String,String,T> groupExtractor, BiConsumer<String,T> function)
      For all fields whose names match the given regular expression, extract a value from the specified group in the regular expression and call the supplied function.
      Parameters:
      regex - the regular expression string; may not be null
      groupNumber - the number of the regular expression group containing the string value to be extracted; must be positive
      groupExtractor - the function that extracts the value from the group
      function - the consumer that takes the value of matching field and the value extracted from the field name; may not be null
    • forEach

      default <T> void forEach(BiConsumer<String,String> function)
      Call the supplied function for each of the fields.
      Parameters:
      function - the consumer that takes the field name and the string value extracted from the field; may not be null