Looking at this further;
The
    public void setProperty( QualifiedName name, Object value,
StateHolder valueState )

in AbstractStateModel is actually an freaky method, only called by the
ValueBuilder, passing the object one want it to change...

The ValueBuilder already has what it needs and I am suggesting change
the ValueBuilder to a more straight forward implementation;

    public ValueBuilder<T> withState( StateHolder state )
    {
        final StateHolder valueState = getState();
        state.visitProperties( new StateHolder.StateVisitor<RuntimeException>()
        {
            public void visitProperty( QualifiedName name, Object value )
            {
                Property<Object> property = valueState.getProperty( name );
                if( property != null )
                {
                    property.set( value );
                }
            }

we can get rid of that method altogether, and I think make the
withState code a little bit cleaner.


As for the "iterate over the value state, and for each property pull
it from the entity", I think it is less clean, since one still have to
rely on Constraints and ignore things not found, since that could be
valid via @Optional or @UseDefaults set up.

So, I think the above change is the right way to go, and I am
committing that later today.


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/24svnvk
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to