Coat is an annotation processor to generate classes for reading configuration values into typesafe objects.
The generated config implementation is
-
easy to use
-
type-safe
-
very fast
-
thread-safe
-
Define an interface representing your config object.
import de.poiu.coat.annotation.Coat; @Coat.Config public interface MyConfig { public String appName(); public int listenPort(); public Optional<String> description(); }
-
Let the Coat annotation processor create the concrete implementation.
-
Use the generated class.
try { final MyConfig config= MyConfigBuilder.from(new File("/path/to/config.properties")); final String appName= config.appName(); final int listenPort= config.listenPort(); config.description().ifPresent( … ); } catch (final ConfigValidationException ex) { System.err.println("Error in config file:\n" + ex.getValidationResult().toString()); System.exit(1); }
Coat has no runtime dependencies on other libraries.
The annotation processor has some dependencies on other libraries (which is why it is recommended to use maven as it resolves those dependencies automatically), but none of them are needed at runtime.
Coat can be used with Java 11 or higher.
To use Coat in a maven based project use the following maven coordinates:
<!-- Contains the annotations and converters. Needed at runtime. -->
<dependency>
<groupId>de.poiu.coat</groupId>
<artifactId>coat-runtime</artifactId>
<version>2.0.2</version>
</dependency>
<build>
<plugins>
<!-- The annotation processor. Not needed at runtime. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>de.poiu.coat</groupId>
<artifactId>coat-processor</artifactId>
<version>2.0.2</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
Otherwise download the jar-file of Coat from the Download page and put it into the classpath of your application.
For a more thorough description of the possibilities of Coat read the full documentation.
Coat is licensed under the terms of the Apache license 2.0.