elk
elk copied to clipboard
Add layout option type registration to melk
Due to the changes introduced in pull request #192, a mechanism to register layout option types (that implement IDataObject) should be added to the melk language, e.g.:
type KVector
The type must provide a default constructor and if the type is Cloneable it must implement a reasonable clone method. The following code is then generated as part of the *MetaDataProvider.
ElkReflect.register(KVector.class,
() -> new KVector(),
(v) -> ((KVector)v).clone());
The documentation of layout options must be updated accordingly.
As discussed in #236, the classes generated from the melk language are probably the wrong place for this because they might not be invoked yet when someone tries to access a default value that requires ElkReflect registration. The initialization code should be as close as possible to the actual Java type declaration, e.g. KVector should register itself in a static initializer.