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

Add Java 10 Collectors APIs #236

Closed

Conversation

treblereel
Copy link
Contributor

(cherry picked from commit c5d74f1734bd58a7e3e797a6cc8ca89e2cd7134c)

@gkdn
Copy link
Member

gkdn commented Apr 25, 2024

For some reason I cannot see the rebase option. Do you mind rebasing your PR?

@treblereel
Copy link
Contributor Author

For some reason I cannot see the rebase option. Do you mind rebasing your PR?

give me a sec

@treblereel
Copy link
Contributor Author

@gkdn done

@treblereel
Copy link
Contributor Author

@gkdn is there anything I can help you with?

@gkdn
Copy link
Member

gkdn commented May 4, 2024

Sorry was out of office. Still on my radar, will take a look next week.

}

private static <T, R> Function<T, R> disallowNulls(Function<T, R> func) {
return func.andThen(Objects::requireNonNull);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reuse is not much here; let's implement this explicitly to avoid extra indirect function call for each item

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't clear enough earlier. I meant something like:

  private static <T, R> Function<T, R> disallowNulls(Function<T, R> func) {
    return x -> Object.requireNonNull(func.apply(x));
  }

(otherwise there would be another lambda indirection in each item during collect)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@treblereel I think you missed this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkdn thank you, let me take a look ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkdn fixed

return true;
}

public void testToUnmodifiableList() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move these tests next to other relevant tests.

}

public void testToUnmodifiableList() {
applyItems(List.of("a", "b"), toUnmodifiableList(), "a", "b", (expected, actual) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not overload "equals" checking with assertion behavior.
We can do something like:

applyItems(List.of("a", "b"), toUnmodifiableList(), "a", "b")
assertUnmodifiableCollection(applyItemsWithSplitting(...))

niloc132 and others added 3 commits May 27, 2024 14:39
Fixes #9547

(cherry picked from commit c5d74f1734bd58a7e3e797a6cc8ca89e2cd7134c)
@treblereel treblereel force-pushed the Add_Java_10_Collectors_APIs branch from f128f6f to cddcb29 Compare May 27, 2024 22:56
@treblereel
Copy link
Contributor Author

@gkdn compile: writing output: write $WORK/b106/pkg.a: no space left on device

@gkdn
Copy link
Member

gkdn commented May 28, 2024

@gkdn compile: writing output: write $WORK/b106/pkg.a: no space left on device

Commented on the other PR, pls ignore the error (or help us out fixing it 😅)

@treblereel
Copy link
Contributor Author

@gkdn compile: writing output: write $WORK/b106/pkg.a: no space left on device

Commented on the other PR, pls ignore the error (or help us out fixing it 😅)

I never thought that Google might run out of space

@gkdn
Copy link
Member

gkdn commented May 28, 2024

@gkdn compile: writing output: write $WORK/b106/pkg.a: no space left on device

Commented on the other PR, pls ignore the error (or help us out fixing it 😅)

I never thought that Google might run out of space

Well it is the Github hosted service not Google 😂

}
}

private <K, V> void assertUnmodifiableMap(Map<K, V> a, K existingKey, V existingValue, K newKey,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this helper next to assertUnmodifiableCollection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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

Successfully merging this pull request may close these issues.

None yet

3 participants