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 KiwiCollections utility class #757

Closed
sleberknight opened this issue Jul 23, 2022 · 0 comments · Fixed by #758
Closed

Add KiwiCollections utility class #757

sleberknight opened this issue Jul 23, 2022 · 0 comments · Fixed by #758
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

Currently each of KiwiLists and KiwiSets has methods that accept their respective type – List and Set – to check if they are null, empty, not null, not empty, etc. But since the argument types are more specialized, if you have a Collection<T>, you can't use them. We should have had these utilities in a utility class that accepts Collection<T> from the beginning, but at this point we can just add a new utility class that accepts Collection<T> as argument types.

I've recently run across situations in several services where I had a collection and wanted to check if (not) null/empty but couldn't use KiwiLists or KiwiSets.

So, KiwiCollections will initially contain the following methods, which are the ones most commonly used:

  • static <T> boolean isNullOrEmpty(Collection<T> collection)
  • static <T> boolean isNotNullOrEmpty(Collection<T> collection)
  • static <T> boolean hasOneElement(Collection<T> collection)
@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Jul 23, 2022
@sleberknight sleberknight added this to the 2.2.0 milestone Jul 23, 2022
@sleberknight sleberknight self-assigned this Jul 23, 2022
sleberknight added a commit that referenced this issue Jul 23, 2022
* Add KiwiCollections with three initial methods:
  - isNullOrEmpty
  - isNotNullOrEmpty
  - hasOneElement
* Refactor KiwiPreconditions to use these new KiwiCollections methods

Closes #757
sleberknight added a commit that referenced this issue Jul 23, 2022
* Add KiwiCollections with three initial methods:
  - isNullOrEmpty
  - isNotNullOrEmpty
  - hasOneElement
* Refactor KiwiPreconditions to use these new KiwiCollections methods

Closes #757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant