Comment #9 on issue 771 by [email protected]:
Annotations.isAllDefaultMethods returns false for method less interfaces.
http://code.google.com/p/google-guice/issues/detail?id=771
I have a key that represents a type and either an Annotation or a Class<?
extends Annotation>
I want to create a new key for a different class that has the same
Annotation or Class<? extends Annotation>
This sounds exactly like Key.ofType:
"Returns a new key of the specified type with the same annotation as this
key"
Using your previous example you could rewrite it as:
private static Key<?> findDependencyKey(TypeLiteral<?> type, Key<?>
clazzKey) {
return classKey.ofType(type);
}
and if you want to guarantee there is at least an annotation instance or
marker then use:
private static Key<?> findDependencyKey(TypeLiteral<?> type, Key<?>
clazzKey) {
if (classKey.getAnnotationType() != null) {
return classKey.ofType(type);
} else {
throw new ProviderException("Neither annotation nor annotation type
found!");
}
}
because Key.getAnnotationType() will only return null when there's no
annotation instance or marker.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev.
For more options, visit https://groups.google.com/groups/opt_out.