Package io.jstach.rainbowgum.annotation
Annotation Interface LogConfigurable
Used to generate Rainbow Gum config builder objects that once built will call the
method annotated with the properties from the generated builder on build. The method
annotated is essentially a factory method that a builder will be generated to configure
each parameter in the factory method. The build call on the builder will call the
annotated factory method.
The above will create a builder called
The builder will try the property
While there exist many annotation processors that generate builders (Immutables for example) the builders generated by this annotation (and corresponding processor) are LogProperties aware such that the builder can extract its arguments from LogProperties.
Here is an example:
class final SomeFactory {
@LogConfigurable(name="MyPluginBuilder", prefix="logging.myplugin.{name}.")
static MyPlugin of(@KeyParameter String name, Integer myParameter) {
// do some additional logic.
return new MyPlugin(name, myParameter);
}
}
MyPluginBuilder with a setter of
myParameter and its constructor will take a String name argument.
MyPlugin plugin = new MyPluginBuilder("example").myParameter(80).fromProperties(properties).build();
logging.myplugin.example.myParameter and
use it if it exists to override the 80 value.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceWall call a static method on the factory class (the class that contains the annotatedLogConfigurablemethod) with the property value as a string to be converted.static @interfaceUse to set static defaults to parameters.static @interfaceUse as parameter to property keys with parameters.static @interfaceA parameter not to be configured with properties that will just pass through to the build method. -
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
name
Name of builder.- Returns:
- name of builder by default if not set Builder will be suffixed to targetType.
- Default:
""
-
prefix
Property prefix to use for property lookup. Usually these come from LogProperties string constants and have a parameter of "name". If the prefix has parameters they can be specified withLogConfigurable.KeyParameteras arguments on the static factory method.An example might be: "logging.component.{name}." which has a parameter of "name".
- Returns:
- prefix in general should end in ".".
- See Also:
-