0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dagger2入門 - basic(@Named & @Qualifier)

Posted at

概要

@Namedを利用する

コード

結果

Red
Blue

Process finished with exit code 0

説明

  • @Injectで引数違いインスタンスを区別できないが、@Namedを利用して同じクラスのインスタンスを分けれる
  • しかし、@Named("SelfType_red")に「SelfType_red」の定義が使いにくい

@Qualifier

コード

結果

QualifierRed
QualifierBlue

Process finished with exit code 0

説明

  • @Qualifierで新しいannotationを定義して文字列(SelfType_red)より使いやすい
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?