owner
owner copied to clipboard
Is it possible to define non-public Preprocessors?
I want to add a Preprocessor
to one of my properties, as in below code. I would also like the ToUpperCase
Preprocessor NOT to be exposed in my public API (i.e. make it private or package-private), is it possible? The below code fails due to ToUpperCase
is private. Are there any workarounds?
If no workaround is available, would it make sense to change OWNER to suppress Java language access checking when instantiating classes through reflection? I mean, it would be nicer if OWNER didn't force API developers to expose more than necessary in their API's.
If above makes sense I can provide a pull request.
import org.aeonbits.owner.Config;
import org.aeonbits.owner.ConfigFactory;
import org.aeonbits.owner.Preprocessor;
public class Example {
public static void main(String[] args) {
MyConfig conf = ConfigFactory.create(MyConfig.class);
System.out.println(conf.propA());
}
public interface MyConfig extends Config {
@Key("prop.a")
@DefaultValue("a")
@PreprocessorClasses(ToUpperCase.class)
String propA();
}
private static class ToUpperCase implements Preprocessor {
@Override
public String process(String input) {
return input.toUpperCase();
}
}
}