-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into add-ingest-transform-…
…type
- Loading branch information
Showing
6 changed files
with
59 additions
and
93 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/regnosys/testing/pipeline/PipelineFilter.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.regnosys.testing.pipeline; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.BiPredicate; | ||
import java.util.function.Predicate; | ||
|
||
public class PipelineFilter implements Predicate<String> { | ||
|
||
private final List<String> items; | ||
private final BiPredicate<String, String> predicate; | ||
|
||
private PipelineFilter(List<String> items, BiPredicate<String, String> predicate) { | ||
this.items = items; | ||
this.predicate = predicate; | ||
} | ||
|
||
public boolean test(String item) { | ||
return items.stream().anyMatch(x -> predicate.test(item, x)); | ||
} | ||
|
||
public static Predicate<String> startsWith(String... startsFilter) { | ||
return new PipelineFilter(Arrays.asList(startsFilter), String::startsWith); | ||
} | ||
|
||
public static Predicate<String> contains(String... startsFilter) { | ||
return new PipelineFilter(Arrays.asList(startsFilter), String::contains); | ||
} | ||
|
||
public static Predicate<String> equalsTo(String... startsFilter) { | ||
return new PipelineFilter(Arrays.asList(startsFilter), String::equals); | ||
} | ||
|
||
public static Predicate<String> startsWith(List<String> startsFilterDefaults, String... startsFilter) { | ||
Collections.addAll(startsFilterDefaults, startsFilter); | ||
return new PipelineFilter(startsFilterDefaults, String::startsWith); | ||
} | ||
} |
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
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
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
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
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