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

chore: small code and doc improvements #104

Merged
merged 3 commits into from
Aug 16, 2021
Merged

Conversation

skaldarnar
Copy link
Contributor

@skaldarnar skaldarnar commented Aug 15, 2021

Some comments and code improvements done while adding new building templates to Metal Reneges. I thought those explanations might be helpful to have in place, as well as some code improvements to make the work with Optionals a bit more idiomatic here.

@skaldarnar skaldarnar added Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Type: Chore Request for or implementation of maintenance changes labels Aug 15, 2021
@skaldarnar skaldarnar requested review from keturn and naalit August 15, 2021 21:49
Copy link
Contributor

@naalit naalit left a comment

Choose a reason for hiding this comment

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

This is definitely an improvement, it makes it easier to understand what's going on here.

templateNames.stream()
.map(resolver)
.filter(Optional::isPresent)
.map(Optional::get)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wish we were using Java 9 so instead of .filter().map() it could be

templateNames.stream()
    .map(resolver)
    .flatMap(Optional::stream)

I learned there's actually Streams::stream for that purpose in Guava, but that's marked beta and this isn't actually a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I know 🙈 Should probably add a comment here marking this as a potential Java 9+ improvement.

@skaldarnar skaldarnar merged commit 8f15ea8 into develop Aug 16, 2021
@skaldarnar skaldarnar deleted the chore/small-improvements branch August 16, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Type: Chore Request for or implementation of maintenance changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants