Define the Pattern interface and its core methods
This commit is contained in:
parent
3808613a58
commit
d88f6a05f9
@ -0,0 +1,28 @@
|
||||
package it.cavallium.warppi.math.rules.dsl;
|
||||
|
||||
import it.cavallium.warppi.math.Function;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Recognizes and generates functions of some specific shape.
|
||||
*/
|
||||
public interface Pattern {
|
||||
/**
|
||||
* Tries to match this pattern against a function and capture sub-functions.
|
||||
*
|
||||
* @param function The function to test the pattern against.
|
||||
* @return The captured sub-functions, or an empty <code>Optional</code> if
|
||||
* the pattern doesn't match.
|
||||
*/
|
||||
Optional<Map<String, Function>> match(Function function);
|
||||
|
||||
/**
|
||||
* Creates a new function by filling in sub-functions within this pattern.
|
||||
*
|
||||
* @param subFunctions A map of named sub-functions to be inserted into this pattern.
|
||||
* @return The resulting function.
|
||||
*/
|
||||
Function replace(Map<String, Function> subFunctions);
|
||||
}
|
Loading…
Reference in New Issue
Block a user