Skip to content

Instantly share code, notes, and snippets.

@vple
Last active May 27, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vple/a98af33bf2f75ff60cb1ce9a7a3da0e3 to your computer and use it in GitHub Desktop.
Save vple/a98af33bf2f75ff60cb1ce9a7a3da0e3 to your computer and use it in GitHub Desktop.
Reusable matches color spec
/**
* Determines if the given objects have the specified color.
*/
public class MatchesColorSpec {
private final Color color;
public MatchesColorSpec(Color color) {
this.color = color;
}
public boolean isSatisfiedBy(Collection<Colored> objects) {
return objects.stream()
.allMatch(object -> object.hasColor(color));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment