2017-07-24 13:44:38 -07:00
|
|
|
package org.nwapw.abacus.number;
|
|
|
|
|
2017-07-24 14:26:09 -07:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2017-07-24 13:44:38 -07:00
|
|
|
public abstract class Function {
|
|
|
|
|
2017-07-25 13:58:09 -07:00
|
|
|
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);
|
|
|
|
}};
|
|
|
|
|
2017-07-25 13:58:09 -07:00
|
|
|
protected abstract boolean matchesParams(NumberInterface[] params);
|
|
|
|
protected abstract NumberInterface applyInternal(NumberInterface[] params);
|
2017-07-24 13:44:38 -07:00
|
|
|
|
2017-07-25 13:58:09 -07:00
|
|
|
public NumberInterface apply(NumberInterface...params) {
|
2017-07-24 14:03:55 -07:00
|
|
|
if(!matchesParams(params)) return null;
|
2017-07-24 13:44:38 -07:00
|
|
|
return applyInternal(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|