Annotation Interface Overwrite


@Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface Overwrite
Marks a field or method in a configuration class as overridable at runtime.

When a configuration class contains fields or methods annotated with @Overwrite, the annotation processor (OcularProcessor) will generate a helper class at compile time that knows how to look up override values from environment variables and/or system properties.

You can specify one or more Env and/or Prop sources. The order you declare them matters: the first source that provides a value wins. For example:


 @Overwrite(prop = @Prop(), env = @Env())
 private String host;
 
This will first check the system property, then the environment variable. If both are set, the system property wins because it is declared first.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the override.
    Env[]
    Environment variable sources to check for an override value.
    System property sources to check for an override value.
  • Element Details

    • env

      Env[] env
      Environment variable sources to check for an override value.
      Default:
      {}
    • prop

      Prop[] prop
      System property sources to check for an override value.
      Default:
      {}
    • description

      String description
      Description of the override.
      Default:
      ""