ashley
ashley copied to clipboard
Support for @NotNull annotation
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...?
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.
Hello again!
Thanks for your patience.
I updated the pull request:
- the annotation
@NotNullis only needed for compiling. - bump libgdx to the 1.9.10 which lead to a small fix on the
ImmutableArrayclass (seetoArrayMethod. 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:

With @NotNull while setting a family with a null value:
Please see the red wave
Without @NotNull while creating a new IteratingSystem:

With @NotNull while creating a new IteratingSystem:
Please see the Entity instead of Entity? (which mean that the entity argument can be null in this later case)
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.