ashley icon indicating copy to clipboard operation
ashley copied to clipboard

Support for @NotNull annotation

Open dwursteisen opened this issue 6 years ago • 4 comments
trafficstars

dwursteisen avatar Jun 04 '19 21:06 dwursteisen

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...?

dsaltares avatar Aug 21 '19 14:08 dsaltares

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.

dwursteisen avatar Aug 21 '19 21:08 dwursteisen

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)

dwursteisen avatar Aug 30 '19 09:08 dwursteisen

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 https://github.com/libgdx/libgdx/pull/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.

metaphore avatar Nov 05 '20 14:11 metaphore