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 orThrow and orDefault methods to Index #741

Merged
merged 5 commits into from Apr 2, 2022

Conversation

Machine-Maker
Copy link
Member

@Machine-Maker Machine-Maker commented Apr 2, 2022

Adds orThrow and orDefault methods to Index. It was kind of annoying how Index#key and Index#value were marked as Nullable when in certain situations you know that they won't return nullable. Like NamedTextColor.NAMES.key(NamedTextColor.RED). These orThrow methods are just helpers to avoid wrapping calls in requireNonNulls or ignoring warnings.

Also added orDefault methods since that's a common map need.

@Machine-Maker Machine-Maker changed the title Add orThrow methods to Index Add orThrow and orDefault methods to Index Apr 2, 2022
Copy link
Member

@zml2008 zml2008 left a comment

Choose a reason for hiding this comment

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

oops, didn't see this second commit

api/src/main/java/net/kyori/adventure/util/Index.java Outdated Show resolved Hide resolved
api/src/main/java/net/kyori/adventure/util/Index.java Outdated Show resolved Hide resolved
api/src/main/java/net/kyori/adventure/util/Index.java Outdated Show resolved Hide resolved
api/src/main/java/net/kyori/adventure/util/Index.java Outdated Show resolved Hide resolved
@Machine-Maker
Copy link
Member Author

addressed those requested changes and the check style errors

Copy link
Member

@kezz kezz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@kezz kezz added this to the 4.11.0 milestone Apr 2, 2022
Copy link
Member

@zml2008 zml2008 left a comment

Choose a reason for hiding this comment

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

thanks!

@zml2008 zml2008 self-assigned this Apr 2, 2022
@zml2008 zml2008 merged commit 13c388f into KyoriPowered:main/4 Apr 2, 2022
@Machine-Maker Machine-Maker deleted the feature/index-orThrow branch April 3, 2022 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants