FYI, there's a class hidden away in
com.google.inject.internal.UniqueAnnotations that does this (in a slightly cleaner/simpler way). It's in internal, so not part of the public API and is subject to change/moving/deletion/etc... but so many folks use it that it's probably worthwhile promoting it to c.g.i.util. Note, though, that it's just a unique *annotation*, not a unique key. Key is still a combination of a TypeLiteral & a binding annotation, as Colin mentioned. So you'd use something like Key.get(YourClass.class, UniqueAnnotations.create()) instead of a helper getUniqueKey(Class) method, which I'd argue is a little more understandable and keeps the concepts well-separated.
--
You received this message because you are subscribed to the Google Groups "google-guice" group.