| 284 | } |
| 285 | |
| 286 | private static final class EquivalentToPredicate<T> implements Predicate<T>, Serializable { |
| 287 | private final Equivalence<T> equivalence; |
| 288 | |
| 289 | @Nullable |
| 290 | private final T target; |
| 291 | |
| 292 | EquivalentToPredicate(Equivalence<T> equivalence, @Nullable T target) { |
| 293 | this.equivalence = checkNotNull(equivalence); |
| 294 | this.target = target; |
| 295 | } |
| 296 | |
| 297 | @Override |
| 298 | public boolean apply(@Nullable T input) { |
| 299 | return equivalence.equivalent(input, target); |
| 300 | } |
| 301 | |
| 302 | @Override |
| 303 | public boolean equals(@Nullable Object obj) { |
| 304 | if (this == obj) { |
| 305 | return true; |
| 306 | } |
| 307 | if (obj instanceof EquivalentToPredicate) { |
| 308 | EquivalentToPredicate<?> that = (EquivalentToPredicate<?>) obj; |
| 309 | return equivalence.equals(that.equivalence) |
| 310 | && Objects.equal(target, that.target); |
| 311 | } |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public int hashCode() { |
| 317 | return Objects.hashCode(equivalence, target); |
| 318 | } |
| 319 | |
| 320 | @Override |
| 321 | public String toString() { |
| 322 | return equivalence + ".equivalentTo(" + target + ")"; |
| 323 | } |
| 324 | |
| 325 | private static final long serialVersionUID = 0; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Returns an equivalence that delegates to {@link Object#equals} and {@link Object#hashCode}. |
nothing calls this directly
no outgoing calls
no test coverage detected