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

Support for @NotNull annotation #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dwursteisen
Copy link
Contributor

No description provided.

@dsaltares
Copy link
Member

Hi @dwursteisen!

Sorry it took me so long to take a look. To be honest, I am not familiar with the @notNull annotation as I haven't touched Java in a LONG time 😅.

Does this simply state that the methods will not work with null values? I guess therefore it helps IDEs tell you when you could potentially be calling these methods with invalid parameters...?

@dwursteisen
Copy link
Contributor Author

dwursteisen commented Aug 21, 2019

I guess therefore it helps IDEs tell you when you could potentially be calling these methods with invalid parameters...?

yes. I added it so when overriding a method from iterateSystem in Kotlin, for example, it will mark the parameter as non nullable, so you don't have to manage the null case, that can't happen.

I'll fix the conflict and add you more information, so you can merge it easily next week.

It will allow language with nullable type support (ie: Kotlin)
to set non-nullable type on @NotNull annotated parameter
(ie: Entity instead of Entity?).
@dwursteisen
Copy link
Contributor Author

Hello again!

Thanks for your patience.

I updated the pull request:

  • the annotation @NotNull is only needed for compiling.
  • bump libgdx to the 1.9.10 which lead to a small fix on the ImmutableArray class (see toArrayMethod . The new version of ashley will need libgdx 1.9.10 because of this API update.

Please see bellow what means the change in IntelliJ:

Without @NotNull while setting a family with a null value:
Capture d’écran 2019-08-30 à 10 58 20

With @NotNull while setting a family with a null value:
Capture d’écran 2019-08-30 à 10 59 39
Please see the red wave

Without @NotNull while creating a new IteratingSystem:
Capture d’écran 2019-08-30 à 11 01 48

With @NotNull while creating a new IteratingSystem:
Capture d’écran 2019-08-30 à 11 01 26
Please see the Entity instead of Entity? (which mean that the entity argument can be null in this later case)

@metaphore
Copy link
Contributor

metaphore commented Nov 5, 2020

As of now, there's an open discussion in the main LibGDX repo about which Nullable annotation to use.

Currently, there's some refactoring is done in libgdx/libgdx#6256 utilizing the javax.annotation.Nullable from com.google.code.findbugs:jsr305 and most likely that's gonna go to the master branch soon.

I guess Ashley should follow the same approach and thus this PR might need to be migrated to the matching annotation.

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.

3 participants