Coat — Config of Annotated Types

Generate typesafe config classes

Coat is an annotation processor to generate classes for reading configuration values into typesafe objects.

Short Usage

  1. For the following config.properties file
 1appName     = My shiny app
 2listenPort  = 5040
 3description = Only a test project
 4
 5
 6
 7
 8
 9
10
  1. Define a corresponding interface
 1import de.poiu.coat.annotation.Coat;
 2
 3@Coat.Config
 4public interface MyConfig {
 5  public String appName();
 6
 7  public int listenPort();
 8
 9  public Optional<String> description();
10}
  1. Then use the generated class
 1final MyConfig config=
 2  MyConfigBuilder.from(
 3    new File("/path/to/config.properties"));
 4
 5final String appName    = config.appName();
 6final int    listenPort = config.listenPort();
 7config.description().ifPresent(
 8  
 9);
10

Example project

See the Example project for a fully executable mini application demonstrating the use of a Coat-generated config class.

License

Coat is licensed under the terms of the Apache license 2.0.