AggregationArguments { public <T extends Expression> Optional<T> positional(Class<T> expected) { if (args.isEmpty()) { return Optional.empty(); } return Optional.of(args.removeFirst().cast(expected)); } AggregationArguments(
        final List<? extends Expression> args, final Map<String, ? extends Expression> kw
    ); List<T> all(final Class<T> expected); Optional<T> positionalOrKeyword(
        final String key, Class<T> expected
    ); Optional<T> positional(Class<T> expected); Optional<T> keyword(final String key, Class<T> expected); void throwUnlessEmpty(final String name);  }
@Test public void positional() { final AggregationArguments arguments = new AggregationArguments(ImmutableList.of(a, b), ImmutableMap.of()); assertEquals(Optional.of(a), arguments.positional(Expression.class)); assertEquals(Optional.of(b), arguments.positional(Expression.class)); assertEquals(Optional.empty(), arguments.positional(Expression.class)); verify(a).cast(Expression.class); verify(b).cast(Expression.class); }