在参考https://dagger.dev/multibindings.html时,有一节讨论了@AutoAnnotation
class MyComponentTest {
@Test void testMyComponent() {
MyComponent myComponent = DaggerMyComponent.create();
assertThat(myComponent.myKeyStringMap()
.get(createMyKey("abc", Abc.class, new int[] {1, 5, 10}))
.isEqualTo("foo");
}
@AutoAnnotation
static MyKey createMyKey(String name, Class<?> implementingClass, int[] thresholds) {
return new AutoAnnotation_MyComponentTest_createMyKey(name, implementingClass, thresholds);
}
}
不知怎的,我从来没有让它发挥作用。
我要添加以下内容到 gradle
implementation 'com.google.auto.value:auto-value:1.5.2'
annotationProcessor 'com.google.auto.value:auto-value:1.5.2'
并且还添加
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
慕神8447489
相关分类