You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 905b5dc
Browse filesBrowse the repository at this point in the historyBrowse files
--- # this is so called 'Yaml Front Matter', read up on it here: http://jekyllrb.com/docs/frontmatter/
2
+
layout: pattern
3
+
title: Filterer Pattern
4
+
folder: filterer
5
+
permalink: /patterns/filterer/
6
+
description: Design pattern that helps container-like objects to return filtered version of themselves.# short meta description that shows in Google search results
7
+
categories:
8
+
- Functional
9
+
tags:
10
+
- Extensibility
11
+
---
12
+
13
+
## Name / classification
14
+
Filterer Pattern
15
+
16
+
## Intent
17
+
The intent of this design pattern is to to introduce a functional interface that will add a functionality for container-like objects to easily return filtered versions of themselves.
18
+
19
+
## Explanation
20
+
The container-like object needs to have a method that returns an instance of `Filterer`. This helper interface gives
21
+
ability to covariantly specify a lower bound of contravariant `Predicate` in the subinterfaces of interfaces representing the container-like objects.
22
+
23
+
## Class diagram
24
+

25
+
26
+
## Applicability
27
+
Pattern can be used when working with container-like objects that use subtyping, instead of parametrizing(generics) for extensible class structure.
28
+
It enables you to easily extend filtering ability of container-like objects as business requirements change.
29
+
30
+
## Tutorials
31
+
*[Article about Filterer pattern posted on it's author's blog](https://blog.tlinkowski.pl/2018/filterer-pattern/)
32
+
*[Application of Filterer pattern in domain of text analysis](https://www.javacodegeeks.com/2019/02/filterer-pattern-10-steps.html)
33
+
34
+
## Known uses
35
+
One of the uses is present on the blog presented in this link. It presents how to use `Filterer` pattern to create text issue anaylyzer with support for test cases used for unit testing.
36
+
37
+
## Consequences (the good and the bad, add criticism here)
38
+
Good :
39
+
* you can easily introduce new subtypes for container-like objects and subtypes for objects that are contained within them and still be able to filter easily be new properties of those new subtypes.
40
+
41
+
Bad :
42
+
* covariant return types mixed with generics can be sometimes tricky
43
+
44
+
## Credits
45
+
* Author of the pattern : [Tomasz Linkowski](https://tlinkowski.pl/)
0 commit comments