jMonkeyEngine / jMonkeyEngine/jmonkeyengine
Allow Savables to be loaded by static builder methods
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
Currently Savables are required to have a parameterless constructor in order to be deserialized by a JmeImporter. This puts some fairly major restrictions on how classes are implemented, even ones that don't implement Savable. I think this can be fixed by allowing Savable classes to specify a static builder method, which is responsible only for instantiating the Savable from the InputCapsule. Further deserialization is performed using the normal read method.
public class MySavable implements Savable {
@SavedObjectBuilder
public static Savable loadSave(InputCapsule in) throws IOException {
return new MySavable(in.readInt("value", 0));
}
}
I've already managed to implemented this on my vulkan fork without any outright breaking changes, so I am curious if this is something we want in jme3 (or whether we want this at all).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JmeImporter deserialization path and the existing parameterless construction of Savable classes. Read the Savable read method and InputCapsule usage alongside the proposed @SavedObjectBuilder entry point. Done means a Savable can be instantiated through a static builder and then receive normal deserialization without requiring a parameterless constructor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100