File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
android/guava/src/com/google/common/base
guava/src/com/google/common/base Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,19 @@ public static Predicate<Class<?>> subtypeOf(Class<?> clazz) {
208208 * helps prevent bugs. This approach doesn't block any potential users since it is always possible
209209 * to use {@code Predicates.<Object>in()}.
210210 *
211+ * <p>You may prefer to use a method reference (e.g., {@code target::contains}) instead of this
212+ * method. However, there are some subtle considerations:
213+ *
214+ * <ul>
215+ * <li>The {@link Predicate} returned by this method is {@link Serializable}.
216+ * <li>The {@link Predicate} returned by this method catches {@link ClassCastException} and
217+ * {@link NullPointerException}.
218+ * <li>Code that chains multiple predicates together (especially negations) may be more readable
219+ * using this method. For example, {@code not(in(target))} is generally more readable than
220+ * {@code not(target::contains)}.
221+ * <li>This method's name conflicts with Kotlin's {@code in} operator.
222+ * </ul>
223+ *
211224 * @param target the collection that may contain the function input
212225 */
213226 @ SuppressWarnings ("NoHardKeywords" ) // We're stuck with the name for compatibility reasons.
Original file line number Diff line number Diff line change @@ -208,6 +208,19 @@ public static Predicate<Class<?>> subtypeOf(Class<?> clazz) {
208208 * helps prevent bugs. This approach doesn't block any potential users since it is always possible
209209 * to use {@code Predicates.<Object>in()}.
210210 *
211+ * <p>You may prefer to use a method reference (e.g., {@code target::contains}) instead of this
212+ * method. However, there are some subtle considerations:
213+ *
214+ * <ul>
215+ * <li>The {@link Predicate} returned by this method is {@link Serializable}.
216+ * <li>The {@link Predicate} returned by this method catches {@link ClassCastException} and
217+ * {@link NullPointerException}.
218+ * <li>Code that chains multiple predicates together (especially negations) may be more readable
219+ * using this method. For example, {@code not(in(target))} is generally more readable than
220+ * {@code not(target::contains)}.
221+ * <li>This method's name conflicts with Kotlin's {@code in} operator.
222+ * </ul>
223+ *
211224 * @param target the collection that may contain the function input
212225 */
213226 @ SuppressWarnings ("NoHardKeywords" ) // We're stuck with the name for compatibility reasons.
You can’t perform that action at this time.
0 commit comments