Last active
May 27, 2018 15:16
-
-
Save vple/a98af33bf2f75ff60cb1ce9a7a3da0e3 to your computer and use it in GitHub Desktop.
Reusable matches color spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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