public interface MyConfiguration {
@Param.String() // Key from method name
String getHost();
@Param.Integer(key = "port", defaultValue = 0)
int getPort();
@Param.Float(key = "threshold", defaultValue = 0.5F)
float getThreshold();
}
MyConfiguration conf = Confy.implement(MyConfiguration.class);
String host = conf.getHost();
int port = conf.getPort();
MyConfiguration conf = Confy.fromArgs(args)
.withProperty("myconf.properties")
.withEnv()
.to(MyConfiguration.class)
String host = conf.getHost();
int port = conf.getPort();
public interface DatabaseConfiguration {
@Param.String()
String getDatabaseHost(); // Env: DATABASE_HOST | Property: database.host
@Param.Integer(defaultValue = 3306)
int getDatabasePort(); // Env: DATABASE_PORT| Property: database.port
}
MyConfiguration conf = Confy.create()
.withProperty("myconf.properties")
.withEnv()
.withArgs(args)
.to(MyConfiguration.class)
MyConfiguration conf = Confy.create()
.withProperty("myconf.properties")
.withArgs(args)
.withEnv()
.to(MyConfiguration.class)
test.properties
my.env=confy
environment
MY_ENV=confy-env
Get using same key
confy.get("my.env"): "confy-env"
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.GaruGaru</groupId>
<artifactId>confy2</artifactId>
<version>1.3</version>
</dependency>