|
1 | 1 | package io.javaoperatorsdk.operator.api.config.informer;
|
2 | 2 |
|
| 3 | +import java.util.AbstractMap; |
| 4 | +import java.util.ArrayList; |
3 | 5 | import java.util.Collection;
|
4 | 6 | import java.util.Collections;
|
| 7 | +import java.util.HashMap; |
| 8 | +import java.util.List; |
| 9 | +import java.util.Map; |
5 | 10 | import java.util.Set;
|
6 | 11 | import java.util.stream.Collectors;
|
7 | 12 |
|
@@ -36,6 +41,8 @@ public class InformerConfiguration<R extends HasMetadata> {
|
36 | 41 | private GenericFilter<? super R> genericFilter;
|
37 | 42 | private ItemStore<R> itemStore;
|
38 | 43 | private Long informerListLimit;
|
| 44 | + private Map<String, String> withFields = new HashMap<>(); |
| 45 | + private List<AbstractMap.SimpleEntry<String, String>> withoutFields = new ArrayList<>(); |
39 | 46 |
|
40 | 47 | protected InformerConfiguration(
|
41 | 48 | Class<R> resourceClass,
|
@@ -264,6 +271,14 @@ public Long getInformerListLimit() {
|
264 | 271 | return informerListLimit;
|
265 | 272 | }
|
266 | 273 |
|
| 274 | + public Map<String, String> getWithFields() { |
| 275 | + return withFields; |
| 276 | + } |
| 277 | + |
| 278 | + public List<AbstractMap.SimpleEntry<String, String>> getWithoutFields() { |
| 279 | + return withoutFields; |
| 280 | + } |
| 281 | + |
267 | 282 | @SuppressWarnings("UnusedReturnValue")
|
268 | 283 | public class Builder {
|
269 | 284 |
|
@@ -424,5 +439,27 @@ public Builder withInformerListLimit(Long informerListLimit) {
|
424 | 439 | InformerConfiguration.this.informerListLimit = informerListLimit;
|
425 | 440 | return this;
|
426 | 441 | }
|
| 442 | + |
| 443 | + public Builder withField(String field, String value) { |
| 444 | + InformerConfiguration.this.withFields.put(field, value); |
| 445 | + return this; |
| 446 | + } |
| 447 | + |
| 448 | + public Builder withFields(Map<String, String> fields) { |
| 449 | + InformerConfiguration.this.withFields.putAll(fields); |
| 450 | + return this; |
| 451 | + } |
| 452 | + |
| 453 | + /** |
| 454 | + * Note that there can be more values for the same field. Like key != value1,key != value2. |
| 455 | + * |
| 456 | + * @param field key |
| 457 | + * @param value negated |
| 458 | + * @return builder |
| 459 | + */ |
| 460 | + public Builder withoutField(String field, String value) { |
| 461 | + InformerConfiguration.this.withoutFields.add(new AbstractMap.SimpleEntry<>(field, value)); |
| 462 | + return this; |
| 463 | + } |
427 | 464 | }
|
428 | 465 | }
|
0 commit comments