@Test public void testMultipleClassifiersInTreeSet() { Key<String> keyWithoutClassifier = Key.get(String.class); Key<String> keyWithClassifier = Key.get(String.class, Text.class); Key<String> keyWithAnotherClassifier = Key.get(String.class, MyClassifier.class); TreeSet<Key<?>> keySet = Sets.newTreeSet(); keySet.add(keyWithoutClassifier); assumeThat(keySet.add(keyWithAnotherClassifier), is(true)); boolean added = keySet.add(keyWithClassifier); assertThat( "two keys with different classifiers must be accepted in a single set", added, is(true)); assertThat( "other classifier must be contained in set", keySet.contains(Key.get(String.class, MyClassifier.class)), is(true)); }
public static <T> Key<T> get(Class<T> type) { return new Key<T>(type, null); }
Key implements Comparable<Key<?>> { public static <T> Key<T> get(Class<T> type) { return new Key<T>(type, null); } }
Key implements Comparable<Key<?>> { public static <T> Key<T> get(Class<T> type) { return new Key<T>(type, null); } private  Key(Type type, @Nullable Class<? extends Annotation> classifier); }
Key implements Comparable<Key<?>> { public static <T> Key<T> get(Class<T> type) { return new Key<T>(type, null); } private  Key(Type type, @Nullable Class<? extends Annotation> classifier); static Key<T> get(Class<T> type); static Key<T> get(Class<T> type, @Nullable Class<? extends Annotation> classifier); static Key<T> get(Type type); static Key<T> get(Type type, @Nullable Class<? extends Annotation> classifier); Type getType(); @Nullable Class<? extends Annotation> getClassifier(); Key<T> setClassifier(@Nullable Class<? extends Annotation> classifier); boolean matches(Key<T> key); @Override int compareTo(Key<?> o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Key implements Comparable<Key<?>> { public static <T> Key<T> get(Class<T> type) { return new Key<T>(type, null); } private  Key(Type type, @Nullable Class<? extends Annotation> classifier); static Key<T> get(Class<T> type); static Key<T> get(Class<T> type, @Nullable Class<? extends Annotation> classifier); static Key<T> get(Type type); static Key<T> get(Type type, @Nullable Class<? extends Annotation> classifier); Type getType(); @Nullable Class<? extends Annotation> getClassifier(); Key<T> setClassifier(@Nullable Class<? extends Annotation> classifier); boolean matches(Key<T> key); @Override int compareTo(Key<?> o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }