In java, I have a class like this:
public class MyClass extends Properties {
public StringProperty prop1 = new StringProperty(this, "default value for prop1");
public StringProperty prop2 = new StringProperty(this, "prop2 default val");
}//MyClass
The parent class "Properties" uses reflection to look for all public fields in itself, and fills the variables with values as needed.
How would I extend Properties in scala? Using var prop1:StringProperty ...
does not work, I'm assuming due to how scala converts private fields to get... set... type methods.
Scala marks the field as private, but generates accessor methods to set and get its value. If you want to use reflection to do this, you can do this the way that is described: here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With