@Override
    public Result analyze(Expression filter) {
      Objects.requireNonNull(filter, "filter");
      if (!(filter instanceof Call)) {
        return NOT_OPTIMIZABLE;
      }

      final Call predicate = (Call) filter;
      // require "equal" or "in" operators
      if (!(predicate.operator() == Operators.EQUAL || predicate.operator() == Operators.IN)) {
        return NOT_OPTIMIZABLE;
      }

      final List<Expression> args = predicate.arguments();
      Preconditions.checkArgument(args.size() == 2, "Expected size 2 but got %s for %s",
              args.size(), predicate);


      if (!(args.get(0) instanceof Path && args.get(1) instanceof Constant)) {
        // second argument should be a constant
        return NOT_OPTIMIZABLE;
      }

      final Path path = Visitors.toPath(predicate.arguments().get(0));

      if (!idPath.equals(path)) {
        return NOT_OPTIMIZABLE;
      }

      // extract values
      Set<?> values = ImmutableSet.copyOf(Visitors.toConstant(predicate.arguments().get(1)).values());
      return new Result() {
        @Override
        public boolean isOptimizable() {
          return true;
        }

        @Override
        public Set<?> values() {
          return values;
        }
      };
    }
Default optimization based on {@link Path}
criteria/geode/src/org/immutables/criteria/geode/KeyLookupAnalyzer.java