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

SLING-10679 wrap every object in a single item list #9

Merged
merged 2 commits into from Jul 28, 2021

Conversation

kwin
Copy link
Member

@kwin kwin commented Jul 28, 2021

No description provided.

@kwin kwin requested review from raducotescu and Buuhuu July 28, 2021 11:00
return list;
}
return Collections.emptyList();
return Collections.singletonList(object);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

@kwin kwin Jul 28, 2021

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

Copy link
Member Author

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.

@sonarcloud
Copy link

sonarcloud bot commented Jul 28, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.9% 92.9% Coverage
0.0% 0.0% Duplication

@kwin kwin merged commit 6bcc04f into master Jul 28, 2021
@kwin kwin deleted the feature/SLING-10679-improve-to-collection branch July 28, 2021 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants