1
バインディングと注釈に関する質問があります。AbstractModuleを実装するクラスのアノテーションオブジェクトをテストする方法
public class MailFacadeImpl implements MailFacade {
private final PersonDao personDao;
@Inject
public MailFacadeImpl(@Mail PersonDao personDao) {
super();
this.personDao = personDao;
}
PersonDaoがカスタムアノテーションを付けている:
は、私は以下のクラスを持っています。 AbstractModuleを実装するクラス内でこの注釈をテストしたいと考えています。ここは、コードの一部です:
bind(new TypeLiteral<SecurityRulesFactory<Person>>(){}).toProvider(FactoryProvider.newFactory(
new TypeLiteral<SecurityRulesFactory<Person>>(){}, new TypeLiteral<MailSecurityRulesCrdb>(){}));
私はと類似気にいらがしたい:
if(PersonDAO is annotated with(Mail.class)){
bind(new TypeLiteral<SecurityRulesFactory<Person>>(){}).toProvider(FactoryProvider.newFactory(
new TypeLiteral<SecurityRulesFactory<Person>>(){}, new TypeLiteral<MailSecurityRulesCrdb>(){}));
}
を、あなたはそれが可能だと思いますか?
あなたの助けを借りて:-) いい金曜日にお過ごしください!
私はこれを見つけました:PersonDao.class.isAnnotationPresent(Mail.class)。多分それは動作します。私はテストします。 – AbstractMan