Created
November 3, 2018 19:46
-
-
Save xjjon/d80adf8e5febaaec398ee59a16bad0aa to your computer and use it in GitHub Desktop.
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
package filters; | |
import java.util.List; | |
@AllArgsConstructor | |
public class AndFilter implements Filter { | |
private final List<Filter> filters; | |
@Override | |
public boolean isFiltered(Object object) { | |
return filters.stream().allMatch(filter -> isFiltered(object)); | |
} | |
} |
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
package filters; | |
public interface Filter<I> { | |
boolean isFiltered(I object); | |
} |
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
package filters; | |
import java.util.List; | |
@AllArgsConstructor | |
public class OrFilter implements Filter { | |
private final List<Filter> filters; | |
@Override | |
public boolean isFiltered(Object object) { | |
return filters.stream().anyMatch(filter -> isFiltered(object)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment