Source:
<code>public Expr apply(final List<Expr> args) { if (args.size() < 2 || 3 < args.size()) { throw new IAE(createErrMsg("must have 2-3 arguments")); } boolean inclusive = getInclusive(args); SubnetUtils.SubnetInfo subnetInfo = getSubnetInfo(args, inclusive); Expr arg = args.get(0); class IPv4AddressMatchExpr extends ExprMacroTable.BaseScalarUnivariateMacroFunctionExpr { private final SubnetUtils.SubnetInfo subnetInfo; private IPv4AddressMatchExpr(Expr arg, SubnetUtils.SubnetInfo subnetInfo) { super(arg); this.subnetInfo = subnetInfo; } @Nonnull @Override public ExprEval eval(final ObjectBinding bindings) { ExprEval eval = arg.eval(bindings); boolean match; switch (eval.type()) { case STRING: match = isStringMatch(eval.asString()); break; case LONG: match = !eval.isNumericNull() && isLongMatch(eval.asLong()); break; default: match = false; } return ExprEval.of(match, ExprType.LONG); } private boolean isStringMatch(String stringValue) { boolean match; String ipv4 = IPv4AddressExprUtils.extractIPv4Address(stringValue); if (ipv4 == null) { match = isLongMatch(stringValue); } else { match = subnetInfo.isInRange(ipv4); } return match; } private boolean isLongMatch(String stringValue) { boolean match; try { <START> long longValue = Long.parseLong(stringValue); <END> match = isLongMatch(longValue); } catch (NumberFormatException ignored) { match = false; } return match; } private boolean isLongMatch(long longValue) { return !IPv4AddressExprUtils.overflowsUnsignedInt(longValue) && subnetInfo.isInRange((int) longValue); } @Override public Expr visit(Shuttle shuttle) { Expr newArg = arg.visit(shuttle); return shuttle.visit(new IPv4AddressMatchExpr(newArg, subnetInfo)); } } return new IPv4AddressMatchExpr(arg, subnetInfo); }</code><technical_language>GuavaUtils.tryParseLong speedier non-longs, throw exceptions stack traces filled in</technical_language>

Target:
public Expr apply(final List<Expr> args) { if (args.size() != 2) { throw new IAE(ExprUtils.createErrMsg(name(), "must have 2 arguments")); } SubnetUtils.SubnetInfo subnetInfo = getSubnetInfo(args); Expr arg = args.get(0); class IPv4AddressMatchExpr extends ExprMacroTable.BaseScalarUnivariateMacroFunctionExpr { private final SubnetUtils.SubnetInfo subnetInfo; private IPv4AddressMatchExpr(Expr arg, SubnetUtils.SubnetInfo subnetInfo) { super(arg); this.subnetInfo = subnetInfo; } @Nonnull @Override public ExprEval eval(final ObjectBinding bindings) { ExprEval eval = arg.eval(bindings); boolean match; switch (eval.type()) { case STRING: match = isStringMatch(eval.asString()); break; case LONG: match = !eval.isNumericNull() && isLongMatch(eval.asLong()); break; default: match = false; } return ExprEval.of(match, ExprType.LONG); } private boolean isStringMatch(String stringValue) { return IPv4AddressExprUtils.isValidAddress(stringValue) && subnetInfo.isInRange(stringValue); } private boolean isLongMatch(long longValue) { return !IPv4AddressExprUtils.overflowsUnsignedInt(longValue) && subnetInfo.isInRange((int) longValue); } @Override public Expr visit(Shuttle shuttle) { Expr newArg = arg.visit(shuttle); return shuttle.visit(new IPv4AddressMatchExpr(newArg, subnetInfo)); } } return new IPv4AddressMatchExpr(arg, subnetInfo); }