下面列出了怎么用com.google.inject.ImplementedBy的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void configure() {
final ImplementedBy implementedBy = type.getRawType().getAnnotation(ImplementedBy.class);
bind(parserKey).toInstance(new ReflectiveParserImpl(
implementedBy != null ? implementedBy.value() : this.baseClass,
Members.annotations(Parseable.Property.class, Methods.declaredMethodsInAncestors(type.getRawType()))
.merge(this::createProperty)
.collect(Collectors.toImmutableList())
));
}
@Test public void testParameterizedAnnotationOnType_01() throws Exception {
final String text = "@com.google.inject.ImplementedBy(typeof(String)) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testParameterizedAnnotationOnType_02() throws Exception {
final String text = "@com.google.inject.ImplementedBy(String) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testParameterizedAnnotationOnType_03() throws Exception {
final String text = "@com.google.inject.ImplementedBy(java.lang.String) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testParameterizedAnnotationOnType_04() throws Exception {
final String text = "@com.google.inject.ImplementedBy(java.util.Map.Entry) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == Map.Entry.class);
}
@Test public void testParameterizedAnnotationOnType_05() throws Exception {
final String text = "@com.google.inject.ImplementedBy(java.util.Map$Entry) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == Map.Entry.class);
}
@Test public void testKeyValueParameterizedAnnotationOnType_01() throws Exception {
final String text = "@com.google.inject.ImplementedBy( value = typeof(String)) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testKeyValueParameterizedAnnotationOnType_02() throws Exception {
final String text = "@com.google.inject.ImplementedBy( value = String) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testKeyValueParameterizedAnnotationOnType_03() throws Exception {
final String text = "@com.google.inject.ImplementedBy( value = java.lang.String) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == String.class);
}
@Test public void testKeyValueParameterizedAnnotationOnType_04() throws Exception {
final String text = "@com.google.inject.ImplementedBy( value = java.util.Map.Entry) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == Map.Entry.class);
}
@Test public void testKeyValueParameterizedAnnotationOnType_05() throws Exception {
final String text = "@com.google.inject.ImplementedBy( value = java.util.Map$Entry) class Foo {}";
ImplementedBy implementedBy = getAnnotationOnClass(text, ImplementedBy.class);
assertTrue(implementedBy.value() == Map.Entry.class);
}