001package io.avaje.inject.spi;
002
003import java.util.Optional;
004
005import io.avaje.lang.NonNullApi;
006
007/**
008 * Plugin interface which contains the application properties used for wiring. Used with {@link
009 * io.avaje.inject.RequiresProperty} and {@link io.avaje.inject.Profile}.
010 *
011 * <p>The plugin is loaded via ServiceLoader and defaults to an implementation that uses {@link
012 * System#getProperty(String)} and {@link System#getenv(String)}.
013 */
014@NonNullApi
015public interface PropertyRequiresPlugin {
016
017  /**
018   * Return a configuration value that might not exist.
019   */
020  Optional<String> get(String property);
021
022  /**
023   * Return true if the property is defined.
024   */
025  boolean contains(String property);
026
027  /** Return true if the property is not defined. */
028  default boolean missing(String property) {
029    return !contains(property);
030  }
031
032  /** Return true if the property is equal to the given value. */
033  boolean equalTo(String property, String value);
034
035  /** Return true if the property is not defined or not equal to the given value. */
036  default boolean notEqualTo(String property, String value) {
037    return !equalTo(property, value);
038  }
039
040}