Skip to content

Simplify SortedProperties.entrySet()#2629

Open
rovarga wants to merge 1 commit intoapache:mainfrom
rovarga:sortedprops
Open

Simplify SortedProperties.entrySet()#2629
rovarga wants to merge 1 commit intoapache:mainfrom
rovarga:sortedprops

Conversation

@rovarga
Copy link
Copy Markdown
Contributor

@rovarga rovarga commented May 2, 2026

Use Comparator.comparing() and Collectors.toCollection() to make the
method much more obvious.

Signed-off-by: Robert Varga robert.varga@pantheon.tech

Use Comparator.comparing() and Collectors.toCollection() to make the
method much more obvious.

Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies SortedProperties.entrySet() to make the sorting logic clearer by using Comparator.comparing(...) and collecting directly into a LinkedHashSet, keeping the returned iteration order sorted by key string.

Changes:

  • Replaced the custom comparator + iterator loop with a stream pipeline using Comparator.comparing(...).
  • Collected the sorted entries via Collectors.toCollection(LinkedHashSet::new).
  • Removed the now-unused Iterator import and added Collectors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +45
return super.entrySet().stream()
.sorted(Comparator.comparing(entry -> entry.getKey().toString()))
.collect(Collectors.toCollection(LinkedHashSet::new));
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.

2 participants