summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/patterns/IPatternMatcher.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-12-03 19:28:15 -0500
committerBen Culkin <scorpress@gmail.com>2020-12-03 19:28:15 -0500
commitf3814a84f8471684cd483347db4fb7b107c2e635 (patch)
tree7ed1061ee69ef50cd1494cfacc866b271b8d1163 /base/src/main/java/bjc/utils/patterns/IPatternMatcher.java
parenta2c7425458f645802a352abc4783e0afc73dba13 (diff)
Rename interfaces to match Java style
Rename several interfaces that were in the style IWhatever, which Java doesn't use
Diffstat (limited to 'base/src/main/java/bjc/utils/patterns/IPatternMatcher.java')
-rw-r--r--base/src/main/java/bjc/utils/patterns/IPatternMatcher.java85
1 files changed, 0 insertions, 85 deletions
diff --git a/base/src/main/java/bjc/utils/patterns/IPatternMatcher.java b/base/src/main/java/bjc/utils/patterns/IPatternMatcher.java
deleted file mode 100644
index b688a47..0000000
--- a/base/src/main/java/bjc/utils/patterns/IPatternMatcher.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package bjc.utils.patterns;
-
-import java.util.function.*;
-
-import bjc.functypes.*;
-
-/**
- * Represents a pattern matcher against a series of patterns.
- *
- * @author Ben Culkin
- *
- * @param <ReturnType> The type returned from matching the patterns.
- * @param <InputType> The type to match against.
- */
-@FunctionalInterface
-public interface IPatternMatcher<ReturnType, InputType> {
- /**
- * Match an input object against a set of patterns.
- *
- * @param input The object to match against.
- *
- * @return The result of matching against the object.
- *
- * @throws NonExhaustiveMatch If none of the patterns in this set match
- */
- ReturnType matchFor(InputType input) throws NonExhaustiveMatch;
-
- /**
- * Create a pattern matcher against a static set of patterns.
- *
- * @param <RetType> The type returned from matching the patterns.
- * @param <InpType> The type to match against.
- *
- * @param patterns The set of patterns to match on.
- *
- * @return A pattern matcher which matches on the given patterns.
- */
- @SafeVarargs
- static <RetType, InpType> IPatternMatcher<RetType, InpType> matchingOn(
- ComplexPattern<RetType, ?, InpType>... patterns) {
- return new PatternMatcher<>(patterns);
- }
-
- /**
- * Create a pattern matcher from a handler function.
- *
- * @param <RetType> The type returned by the matcher.
- * @param <InpType> The type to match against.
- *
- * @param handler The handler function.
- *
- * @return A pattern matcher defined by the given handler.
- */
- static <RetType, InpType> IPatternMatcher<RetType, InpType> from(
- ThrowFunction<InpType, RetType, NonExhaustiveMatch> handler) {
- return new FunctionalPatternMatcher<>(handler);
- }
-
- /**
- * Create a pattern matcher which applies a transform to its input.
- *
- * @param <NewInput> The new input type to use.
- * @param transformer The function to convert from the new input to the old input.
- *
- * @return A pattern matcher which takes values of the new type instead.
- */
- default <NewInput> IPatternMatcher<ReturnType, NewInput> transformInput(
- Function<NewInput, InputType> transformer) {
- return from(inp -> matchFor(transformer.apply(inp)));
- }
-
- /**
- * Create a pattern matcher which applies a transform to its output.
- *
- * @param <NewOutput> The new output type to use.
- *
- * @param transformer The function to convert from the new output to the old output.
- *
- * @return A pattern matcher which takes values of the new type instead.
- */
- default <NewOutput> IPatternMatcher<NewOutput, InputType> transformOutput(
- Function<ReturnType, NewOutput> transformer) {
- return from(inp -> transformer.apply(matchFor(inp)));
- }
-} \ No newline at end of file