File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
common/src/main/java/com/google/auto/common Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,21 @@ protected int doHash(TypeMirror t) {
80
80
}
81
81
}
82
82
83
+ /**
84
+ * Returns an {@link Equivalence} that can be used to compare types. The standard way to compare
85
+ * types is {@link javax.lang.model.util.Types#isSameType Types.isSameType}, but this alternative
86
+ * may be preferred in a number of cases:
87
+ *
88
+ * <ul>
89
+ * <li>If you don't have an instance of {@code Types}.
90
+ * <li>If you want a reliable {@code hashCode()} for the types, for example to construct a set
91
+ * of types using {@link java.util.HashSet} with {@link Equivalence#wrap()}.
92
+ * <li>If you want distinct type variables to be considered equal if they have the same names
93
+ * and bounds.
94
+ * <li>If you want wildcard types to compare equal if they have the same bounds. {@code
95
+ * Types.isSameType} never considers wildcards equal, even when comparing a type to itself.
96
+ * </ul>
97
+ */
83
98
public static Equivalence <TypeMirror > equivalence () {
84
99
return TypeEquivalence .INSTANCE ;
85
100
}
You can’t perform that action at this time.
0 commit comments