Skip to content

Conversation

@spijkercenter
Copy link

  • Introduces a new utility method 'any()' in IterableUtils
  • Returns an Optional containing the first element of an Iterable
  • Handles null and empty iterables, returning an empty Optional

The method is named 'any()' to reflect its behavior of returning any element from the Iterable (specifically, the first one). This naming is consistent with similar concepts in other programming languages and libraries where 'any' often denotes "give me any element that satisfies a condition" - in this case, the condition is simply existence within the Iterable.

This addition provides a convenient way to safely retrieve the first element of an Iterable, wrapped in an Optional, with null-safety built-in.

- Introduces a new utility method 'any()' in IterableUtils
- Returns an Optional containing the first element of an Iterable
- Handles null and empty iterables, returning an empty Optional

The method is named 'any()' to reflect its behavior of returning any
element from the Iterable (specifically, the first one). This naming
is consistent with similar concepts in other programming languages
and libraries where 'any' often denotes "give me any element that
satisfies a condition" - in this case, the condition is simply
existence within the Iterable.

This addition provides a convenient way to safely retrieve the first 
element of an Iterable, wrapped in an Optional, with null-safety built-in.
Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hello @spijkercenter

-1

  • This PR does not compile.
  • Please validate your submissions to avoid wasting the maintainers' time. Compiling code is the most basic requirement.
  • Unfortunately, the PR also has zero unit tests, so it can't be validated.
  • This class does not use Optional and I don't think we want to add variants
  • Try to use the existing APIs, like get() and first() and use Optional in your code

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