All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.config.MultimapConfigProperty Maven / Gradle / Ivy

There is a newer version: 0.4.21.RC1
Show newest version
package io.scalecube.config;

import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.function.BiConsumer;
import java.util.function.Predicate;

/**
 * Multimap config property. Parsable value types supported: string, int, double, long, duration.
 */
public interface MultimapConfigProperty extends ConfigProperty {
  /**
   * Returns value.
   *
   * @return optional multimap value
   */
  Optional>> value();

  /**
   * Shortcut on {@code value().orElse(defaultValue)}.
   *
   * @return existing value or default
   */
  Map> value(Map> defaultValue);

  /**
   * Returns existing value or throws {@link NoSuchElementException} if value is null.
   *
   * @return existing value or exception
   * @throws NoSuchElementException if value is null
   */
  Map> valueOrThrow();

  /**
   * Adds reload callback to the list. Callbacks will be invoked in the order they were added, and
   * only after validation have been passed.
   *
   * @param callback reload callback, 1st argument is old value 2nd one is new value, both are
   *     nullable; though callback may throw exception, this wouldn't stop other callbacks from
   *     execution
   */
  void addCallback(BiConsumer>, Map>> callback);

  /**
   * Adds reload callback to the list. Callbacks will be invoked in the order they were added, and
   * only after validation have been passed.
   *
   * @param executor executor where reload callback will be executed.
   * @param callback reload callback, 1st argument is old value 2nd one is new value, both are
   *     nullable; though callback may throw exception, this wouldn't stop other callbacks from
   *     execution
   */
  void addCallback(
      Executor executor, BiConsumer>, Map>> callback);

  /**
   * Adds validator to the list of validators. Validators will be invoked in the order they were
   * added. An argument to predicate is nullable.
   *
   * @throws IllegalArgumentException in case existing value fails against passed {@code validator}
   */
  void addValidator(Predicate>> validator);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy