Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preditates.sameAs #355

Closed
gissuebot opened this issue Oct 31, 2014 · 1 comment
Closed

Preditates.sameAs #355

gissuebot opened this issue Oct 31, 2014 · 1 comment

Comments

@gissuebot
Copy link

Original issue created by ivankoblik on 2010-04-28 at 10:33 AM


Would be nice to have a standard predicate to do referential equality check.

Possible use case:
ImmutableSet<Object> filteredSet =
  ImmutableSet.copyOf(
    Collections2.filter(
      Predicates.not(
        Predicates.sameAs(objectToRemove)
  )));

I'm not sure how efficient it is, but it's a nifty way of "removing"
elements from immutable collections. Would be glad to learn if there's a
better way of doing it.

@gissuebot
Copy link
Author

Original comment posted by kevinb@google.com on 2010-04-28 at 02:08 PM


Predicates.equalTo() is what you want for this 99% of the time. We used to have a sameAs() predicate internally,
but virtually everyone who used it should have used equalTo(), so we got rid of it.

Btw, for sets you also have the option of Sets.difference(set, ImmutableSet.of(objectToRemove)) (optionally
adding .immutableCopy() to the end of that).


Status: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant