mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-22 07:20:09 -08:00
Make ReducerApplicable an independent interface.
This commit is contained in:
parent
c2feedee32
commit
385a64eace
|
@ -11,20 +11,18 @@ import org.nwapw.abacus.tree.Reducer
|
||||||
* @param <O> the return type of the application.
|
* @param <O> the return type of the application.
|
||||||
* @param <R> the required type of the reducer.
|
* @param <R> the required type of the reducer.
|
||||||
*/
|
*/
|
||||||
interface ReducerApplicable<in T: Any, out O: Any, in R: Any> : Applicable<T, O> {
|
interface ReducerApplicable<in T: Any, out O: Any, in R: Any> {
|
||||||
|
|
||||||
override fun applyInternal(params: Array<out T>): O? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun apply(vararg params: T): O? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this applicable can be applied to the
|
||||||
|
* given parameters.
|
||||||
|
* @param params the parameters to check.
|
||||||
|
*/
|
||||||
|
fun matchesParams(params: Array<out T>): Boolean
|
||||||
/**
|
/**
|
||||||
* Applies this applicable to the given arguments, and reducer.
|
* Applies this applicable to the given arguments, and reducer.
|
||||||
* @param reducer the reducer to use in the application.
|
* @param reducer the reducer to use in the application.
|
||||||
* @param args the arguments to apply to.
|
* @param params the arguments to apply to.
|
||||||
* @return the result of the application.
|
* @return the result of the application.
|
||||||
*/
|
*/
|
||||||
fun applyWithReducerInternal(reducer: Reducer<R>, params: Array<out T>): O?
|
fun applyWithReducerInternal(reducer: Reducer<R>, params: Array<out T>): O?
|
||||||
|
@ -32,7 +30,7 @@ interface ReducerApplicable<in T: Any, out O: Any, in R: Any> : Applicable<T, O>
|
||||||
* Applies this applicable to the given arguments, and reducer,
|
* Applies this applicable to the given arguments, and reducer,
|
||||||
* if the arguments and reducer are compatible with this applicable.
|
* if the arguments and reducer are compatible with this applicable.
|
||||||
* @param reducer the reducer to use in the application.
|
* @param reducer the reducer to use in the application.
|
||||||
* @param args the arguments to apply to.
|
* @param params the arguments to apply to.
|
||||||
* @return the result of the application, or null if the arguments are incompatible.
|
* @return the result of the application, or null if the arguments are incompatible.
|
||||||
*/
|
*/
|
||||||
fun applyWithReducer(reducer: Reducer<R>, vararg params: T): O? {
|
fun applyWithReducer(reducer: Reducer<R>, vararg params: T): O? {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user