Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declarative derived properties for mutable models in Java

Is there a framework for synchronizing properties of POJOs? For example, I want to express (in some high-level, declarative form) that foo.text = bar.text + baz.text or foo.y = (max(bars, y)).y without having to register property change, element add and remove listeners on values and (especially) collections, which are repetitive and error-prone.

like image 326
thSoft Avatar asked May 17 '26 20:05

thSoft


1 Answers

javafx and it's bind operator. For example:

var x = 10;
var y = bind -x + 100;
assert y == 90;        // passes
y = 40;                // bind! 
assert x == 60;        // passes

for java take a look at JSR 295

like image 116
dfa Avatar answered May 19 '26 09:05

dfa