Skip to content

Commit 727a538

Browse files
committed
add GtFilteredCodersModel>>#addOrReplaceFilters:
1 parent 9a66f47 commit 727a538

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/GToolkit-Coder-StreamingCoders/GtFilteredCodersModel.class.st

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ GtFilteredCodersModel >> addOrReplaceFilter: aFilter [
3535
self additionalFilters: newFilters
3636
]
3737

38+
{ #category : #'api - accessing' }
39+
GtFilteredCodersModel >> addOrReplaceFilters: aCollectionOfFilters [
40+
"Add or replace given additional filters.
41+
Each filter of the same filter type (class) is replaced by the given filters."
42+
43+
| newFilters isChanged usedFilters |
44+
45+
isChanged := false.
46+
usedFilters := OrderedCollection new.
47+
newFilters := self additionalFilters
48+
collect: [ :existingFilter |
49+
aCollectionOfFilters
50+
detect: [ :givenFilter |
51+
existingFilter filterType = givenFilter filterType ]
52+
ifFound: [ :givenFilter |
53+
isChanged := true.
54+
usedFilters add: givenFilter.
55+
givenFilter ]
56+
ifNone: [
57+
existingFilter ] ].
58+
59+
isChanged ifFalse: [
60+
newFilters := newFilters , (aCollectionOfFilters copyWithoutAll: usedFilters) ].
61+
self additionalFilters: newFilters
62+
]
63+
3864
{ #category : #'api - accessing' }
3965
GtFilteredCodersModel >> additionalFilters [
4066
<return: #Collection of: #GtSearchFilter>

0 commit comments

Comments
 (0)