private static class Resolver implements DynamicFunctionResolver {
@Override
public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
Preconditions.checkArgument(dataTypes.size() == 2);
DataType firstType = dataTypes.get(0);
if (!(firstType.equals(DataTypes.GEO_POINT) ||
firstType.equals(DataTypes.GEO_SHAPE) ||
firstType.equals(DataTypes.STRING))) {
throw new IllegalArgumentException(String.format(
"%s doesn't take an argument of type \"%s\" as first argument", NAME, firstType));
}
DataType secondType = dataTypes.get(1);
if (!(secondType.equals(DataTypes.GEO_SHAPE) ||
secondType.equals(DataTypes.STRING))) {
throw new IllegalArgumentException(String.format(
"%s doesn't take an argument of type \"%s\" as second argument", NAME, secondType));
}
return new WithinFunction(new FunctionInfo(new FunctionIdent(NAME, dataTypes), DataTypes.BOOLEAN));
}