On Mon, Jun 25, 2012 at 5:00 AM, Kent Sølvsten <[email protected]> wrote:
> ValueBuilder<X> b = vbf.newValueBuilder(X.class);
> X p1 = b.prototype();
> p1.att1().set("value1");
> X inst1 = b.newInstance(); // p1 is now immutable
> X p2 = b.prototype();
> p2.att1().set("value2");
> X inst2 = b.newInstance();
This effectively means that the cookie-cutter approach is not allowed,
right? And the only actual save is to not require an
vbf.newValueBuilder() call again...
There is a another option as well, which isn't too hard.
IF we define that only the 'prototype', i.e. the StateHolder of the
ValueInstance being built, is read/write, but transitive values are
not, then only the StateHolder needs to be cloned, which is far
easier. That means one do;
ValueBuilder<X> b = vbf.newValueBuilder(X.class);
X p1 = b.prototype();
p1.att1().set("value1");
X instance1 = b.newInstance();
p1.att1().set("value2");
X instance2 = b.newInstance();
but not;
ValueBuilder<X> b = vbf.newValueBuilder(X.class);
X p1 = b.prototype();
p1.att1().set(value1);
X instance1 = b.newInstance();
p1.att1().get().att2().set("value2");
X instance2 = b.newInstance();
which kind of makes sense. The trick will be around how to prevent it...
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/6a2pl4j
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev