Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Collections in addition to Arrays in the EQL fluent API #2210

Open
homedirectory opened this issue Mar 18, 2024 · 0 comments · May be fixed by #2211
Open

Allow Collections in addition to Arrays in the EQL fluent API #2210

homedirectory opened this issue Mar 18, 2024 · 0 comments · May be fixed by #2211
Assignees

Comments

@homedirectory
Copy link
Contributor

homedirectory commented Mar 18, 2024

Description

There is a number of methods in EQL's fluent API that have variable arity.

For example:

T allOfValues(final Object... values);

Often the source of argument values to such methods is a Collection, which results in the
following pattern being employed:

Set<Object> ourValues = ...;
... .allOfValues(ourValues.toArray()) ...

It would be beneficial for programming ergonomics to have such methods accept Collection instances directly.

Expected outcome

Fluent API methods are enhanced with additional signatures that accept instances of Collection.

Implementation details

Consider the existence of the following methods in the same class:

// (1)
public void accept(Object... values) {}

// (2)
public void accept(Collection<?> values) {}

Given accept(List.of()), it might at first seem unclear which method is going to be called: both are applicable.

According to the JLS, (2) is more specific, thus it is the one that will be called, which is fitting for the use case of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant