私は次のようなクラスを持っています:
class Foo {
Foo(@Named("x") x) { ... }
}
x
オブジェクトからバインドされProperties
ます:
Names.bindProperties(binder(), props);
しかし、x
設定されていない場合は、 binding をスキップしたいと思いFoo
ます。これを実現する 1 つの方法は次のとおりです。
if (props.contains("x")) {
bind(Foo.class);
}
しかし、より良い方法はありますか?
if (namedPropsBound(Foo.class)) { // how to implement this method?
bind(Foo.class);
}