Change method signature for AppStateManager

AppStateManager provides the method public void attachAll(Iterable<AppState> states).

Unfortunately this does not support subclasses of Appstate. I suggest adapt this method signature to: public void attachAll(Iterable<? extends AppState> states).

PS: I m not very familiar with open source contribution. Is it possible for me create a pull request and wait for approval?

1 Like

That does seem reasonable. That List<MyKindOfAppState> be a legitimate thing to pass in.

The repo for JMonkeyEngine is GitHub - jMonkeyEngine/jmonkeyengine: A complete 3-D game development suite written in Java.

There is a contribution guide at jmonkeyengine/CONTRIBUTING.md at master · jMonkeyEngine/jmonkeyengine · GitHub but broadly yes you can create a PR. You fork the repo, make your changes there and then make a pull request from a branch on your fork into master in the main repo

1 Like

It is a correct API change.

I do have trouble coming up with a good use-case for it, though. In the interest of maybe helping you out of a different design issue, what are you trying to do that requires this?

2 Likes

Basically I have a list of instances that extend Appstate:

private final List<MainApplicationState> appStates;

and in one part of the the code I want to execute one of MainApplicationState methods:

appStates.stream().allMatch(MainApplicationState::isReady)

So I need to use the type List<MainApplicationState> instead of List<AppState>.

But then if I want to attach all states I need to do something like this:

stateManager.attachAll(new ArrayList<>(this.appStates));

or use casting

There is also

appStates.forEach(stateManager::attach);

That will allow you to have appStates be List<MainApplicationState> and is pretty similar to what attachAll does anyway

1 Like