IDEA Live Template for JavaFX Property

IDEA Live Template for JavaFX Property
在IDEA中 JavaFX的property 生成getter,setter, property方法



新建Live Template
(1) Abbreviation:property
(2) Template text:
private $TYPE$Property $NAME$Property = new Simple$TYPE$Property();
public void set$MNAME$($OTYPE$ $NAME$){
    this.$NAME$Property.set($NAME$);
}
public $OTYPE$ get$MNAME$(){
    return this.$NAME$Property.get();
}
public $TYPE$Property $NAME$Property(){
    return $NAME$Property;
}
(3) Applicable in Java: declaration.
(4) Edit Template Variables
TYPE
NAME
OTYPE
MNAME    capitalize(NAME)     [v]

(5)[v] Reformat according to style

测试
property,输入TAB
输入Integer, age, int
生成代码
    private IntegerProperty ageProperty = new SimpleIntegerProperty();
    public void setAge(int age) {
        this.ageProperty.set(age);
    }
    public int getAge() {
        return this.ageProperty.get();
    }
    public IntegerProperty ageProperty() {
        return ageProperty;
    }

======》完美。


===================================
listproperty
===================================
private ObservableList<$TYPE$> $NAME$Property = FXCollections.observableArrayList();
public ObservableList<$TYPE$> $NAME$Property() {
    return $NAME$Property;
}
public List<$TYPE$> get$MNAME$() {
    return $NAME$Property;
}
public void set$MNAME$(List<$TYPE$> $NAME$) {
    this.$NAME$Property = FXCollections.observableArrayList();
    this.$NAME$Property.addAll($NAME$);
}
===================================
mapproperty
===================================

private ObservableMap<$TYPE1$, $TYPE2$> $NAME$Property = FXCollections.observableHashMap();
public ObservableMap<$TYPE1$, $TYPE2$> $NAME$Property() {
    return $NAME$Property;
}
public Map<$TYPE1$, $TYPE2$> get$MNAME$() {
    return $NAME$Property;
}
public void set$MNAME$(Map<$TYPE1$, $TYPE1$> $NAME$) {
    this.$NAME$Property = FXCollections.observableHashMap();
    this.$NAME$Property.putAll($NAME$);
}





你可能感兴趣的:(IDEA Live Template for JavaFX Property)