Is there a Java library that allows you to “deserialize” a properties file directly into an instance of an object?
Example: they say that you have an init.properties file:
username=fisk
password=frosk
and a Java class with some properties:
class Connection {
private String username;
private String password;
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
}
I want to do this:
Connection c = MagicConfigurator.configure("init.properties", new Connection())
and MagicConfigurator will apply all values from the properties file to the Connection instance.
Is there a library with such a class?
source
share