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-24 14:26:09 -07:00
|
|
|
private static final HashMap<Class<? extends Number>, Integer> priorityMap =
|
|
|
|
new HashMap<Class<? extends Number>, Integer>() {{
|
|
|
|
put(NaiveNumber.class, 0);
|
|
|
|
}};
|
|
|
|
|
2017-07-24 14:03:55 -07:00
|
|
|
protected abstract boolean matchesParams(Number[] params);
|
|
|
|
protected abstract Number applyInternal(Number[] params);
|
2017-07-24 13:44:38 -07:00
|
|
|
|
2017-07-24 14:03:55 -07:00
|
|
|
public Number apply(Number...params) {
|
|
|
|
if(!matchesParams(params)) return null;
|
2017-07-24 13:44:38 -07:00
|
|
|
return applyInternal(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|