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
SLING-10679 wrap every object in a single item list #9
Conversation
return list; | ||
} | ||
return Collections.emptyList(); | ||
return Collections.singletonList(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree with the change, I think it comes with a certain risk as it changes the returned collection from a modifiable to an unmodifiable one. Should we make that somehow clear to the consumers?
In general I think we should return unmodifiable collections. Can you change fromIterator()
accordingly as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty list being returned before was also immutable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But not the ArrayList
returned with the single String | Number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the other collections to return immutable lists consistently requires quite some updates in the test (which currently compare with equals against a mutable list), therefore I would like to separate this from this extension. Changing the single element list to be immutable didn't require any test changes.
Also this would require further changes on getIndex(...)
as this cannot work on an object wrapped by Collections.unmodifiableCollection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having a second thought it wasn't that much effort and only one change in the unit test was necessary, therefore I committed those changes in a16076e.
Kudos, SonarCloud Quality Gate passed! |
No description provided.