I have the following code where the Binding.createStringBinding(...)
part is going to be repeated many many times, the only difference is the method used, i.e. getA()
, getB()
, getC()
this.attributeA.bind(Bindings.createStringBinding(() -> {
if(webService.getLastValue() != null){
return webService.getLastValue().getA();
} else{
return "";
}
}, webService.lastValueProperty()));
this.attributeB.bind(Bindings.createStringBinding(() -> {
if(webService.getLastValue() != null){
return webService.getLastValue().getB();
} else{
return "";
}
}, webService.lastValueProperty()));
New: This is the part of the code that I want to make reusable:
Bindings.createStringBinding(() -> {
if(webService.getLastValue() != null){
return webService.getLastValue().getB();
} else{
return "";
}
}, webService.lastValueProperty())
How can I make this reusable? Perhaps making this a function ?