1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-06-17 16:27:07 -07:00
Abacus/src/org/nwapw/abacus/function/Function.java

24 lines
721 B
Java
Raw Normal View History

2017-07-25 21:57:14 -07:00
package org.nwapw.abacus.function;
import org.nwapw.abacus.number.NaiveNumber;
import org.nwapw.abacus.number.NumberInterface;
2017-07-24 14:26:09 -07:00
import java.util.HashMap;
public abstract class Function {
private static final HashMap<Class<? extends NumberInterface>, Integer> priorityMap =
new HashMap<Class<? extends NumberInterface>, Integer>() {{
2017-07-24 14:26:09 -07:00
put(NaiveNumber.class, 0);
}};
protected abstract boolean matchesParams(NumberInterface[] params);
protected abstract NumberInterface applyInternal(NumberInterface[] params);
public NumberInterface apply(NumberInterface...params) {
if(!matchesParams(params)) return null;
return applyInternal(params);
}
}