This NetBeans plugin will help to generate get/set methods for JavaFX properties that are contained within a POJO.
The standard get/set code generator creates the following get/set methods for a JavaFX property which is not ideal:
private StringProperty name;
public StringProperty getName() {
return name;
}
public void setName(StringProperty name) {
this.name = name;
}
This plugin would create the following methods:
public final String getName() {
return name.get();
}
public final void setName(String value) {
name.set(value);
}
public StringProperty nameProperty() {
return name;
}
It's also possible to use variables with the suffix Property
in their names
which will create the following methods:
private StringProperty nameProperty;
public final String getName() {
return nameProperty.get();
}
public final void setName(String value) {
nameProperty.set(value);
}
public StringProperty nameProperty() {
return nameProperty;
}
Read-only properties and read-only wrapper types are also supported:
private ReadOnlyStringProperty identifier;
public final String getIdentifier() {
return identifier.get();
}
public ReadOnlyStringProperty identifierProperty() {
return identifier;
}
private ReadOnlyStringWrapper identifier;
public final String getIdentifier() {
return identifier.get();
}
public ReadOnlyStringProperty identifierProperty() {
return identifier.getReadOnlyProperty();
}
Press Alt-Insert to get the "Generate" popup menu, and select "Java FX Getter and Setter..."
Methods for supported property types will automatically be generated.
- StringProperty
- BooleanProperty
- DoubleProperty
- FloatProperty
- IntegerProperty
- LongProperty
- ListProperty
- MapProperty
- ObjectProperty
- SetProperty
- ReadOnlyStringProperty
- ReadOnlyBooleanProperty
- ReadOnlyDoubleProperty
- ReadOnlyFloatProperty
- ReadOnlyIntegerProperty
- ReadOnlyLongProperty
- ReadOnlyListProperty
- ReadOnlyMapProperty
- ReadOnlyObjectProperty
- ReadOnlySetProperty
- ReadOnlyStringWrapper
- ReadOnlyBooleanWrapper
- ReadOnlyDoubleWrapper
- ReadOnlyFloatWrapper
- ReadOnlyIntegerWrapper
- ReadOnlyLongWrapper
- ReadOnlyListWrapper
- ReadOnlyMapWrapper
- ReadOnlyObjectWrapper
- ReadOnlySetWrapper