Skip to content

Commit

Permalink
Discourage Function.identity().
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 543821637
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jun 27, 2023
1 parent f9a29d7 commit c5255f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion android/guava/src/com/google/common/base/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public String toString() {
}
}

/** Returns the identity function. */
/**
* Returns the identity function.
*
* <p><b>Discouraged:</b> Prefer using a lambda like {@code v -> v}, which is shorter and often
* more readable.
*/
// implementation is "fully variant"; E has become a "pass-through" type
@SuppressWarnings("unchecked")
public static <E extends @Nullable Object> Function<E, E> identity() {
Expand Down
7 changes: 6 additions & 1 deletion guava/src/com/google/common/base/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public String toString() {
}
}

/** Returns the identity function. */
/**
* Returns the identity function.
*
* <p><b>Discouraged:</b> Prefer using a lambda like {@code v -> v}, which is shorter and often
* more readable.
*/
// implementation is "fully variant"; E has become a "pass-through" type
@SuppressWarnings("unchecked")
public static <E extends @Nullable Object> Function<E, E> identity() {
Expand Down

0 comments on commit c5255f1

Please sign in to comment.