A CodeGenerator plugin for Netbeans/jMonkeyEngine that will scan the fields of a class and generate implementations of the read/write methods for Savable for it.
- Tools->Plugins->Downloaded->Add Plugins...
- Find savable-generator in the list
- Restart the IDE as necessary
- Make sure your class implements Savable, but has no read/write method
- Place the cursor somewhere within the target class code
- Hit Alt-Insert (or Source->Insert code...) and select the savable generator from the menu
- Review generated code and save.
- Generally you want to just save all the fields in the class and load them all again
- Array/ArrayList/Map collections of savables are copy/converted as necessary
- Any OtherSavable classes will have their read/write methods generated
- An ArrayList/Map with types will automatically also be generated as well.
The generator uses annotations to configure how it generates code. See the next section for a couple of examples.
To use the annotations, you'll need to include this in your project: jme-exporter-helpers Here is a direct link to the latest .jar file: https://github.com/airbaggins/jme-export-helpers/raw/master/dist/jme3-export-helpers.jar
@SerializeFieldConfig(storageLabel="oldFieldName")
Specify the typeSuffix SerializeFieldConfig parameter with the previous
@SerializeFieldConfig(typeSuffix="Boolean")
int usedToBeABoolean;
@SerializeFieldConfig(typeSuffix="SavableArray")
ArrayList<MySavable> usedToBeAnArray;
@SerializeFieldConfig(setMethod="setLevel", getMethod="getLevel")
int level;
@SerializerMethodConfig(autoGenerated=false)
public void read(...)....
- Type Suffix - the suffix of the jme InputCapsule's read* (and some of the OutputCapsule's write) methods that we can infer a Java type from.
Where I haven't written a converter yet, the code falls back to a straight cast. So mostly you can see quite easily where there are errors to be fixed.
-Bill October 2012