You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/07/17 16:06:26 UTC

[1/7] zest-qi4j git commit: NamedAssociations missing in equals() and hashCode()

Repository: zest-qi4j
Updated Branches:
  refs/heads/develop 858f5baeb -> a0c74a7ba


NamedAssociations missing in equals() and hashCode()


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/d2fbb10c
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/d2fbb10c
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/d2fbb10c

Branch: refs/heads/develop
Commit: d2fbb10c247193410717e891951c41297745553e
Parents: 44f6157
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 08:55:48 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 08:55:48 2015 +0300

----------------------------------------------------------------------
 .../main/java/org/qi4j/runtime/value/ValueStateInstance.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/d2fbb10c/core/runtime/src/main/java/org/qi4j/runtime/value/ValueStateInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/value/ValueStateInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/value/ValueStateInstance.java
index ad5b5f2..3d41470 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/value/ValueStateInstance.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/value/ValueStateInstance.java
@@ -215,7 +215,11 @@ public final class ValueStateInstance
         {
             return false;
         }
-        return manyAssociations.equals( state.manyAssociations );
+        if( !manyAssociations.equals( state.manyAssociations ) )
+        {
+            return false;
+        }
+        return namedAssociations.equals( state.namedAssociations );
     }
 
     @Override
@@ -224,6 +228,7 @@ public final class ValueStateInstance
         int result = properties.hashCode();
         result = 31 * result + associations.hashCode();
         result = 31 * result + manyAssociations.hashCode();
+        result = 31 * result + namedAssociations.hashCode();
         return result;
     }
 }


[7/7] zest-qi4j git commit: Testcase for NamedAssociation equals/hashCode

Posted by ni...@apache.org.
Testcase for NamedAssociation equals/hashCode


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/a0c74a7b
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/a0c74a7b
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/a0c74a7b

Branch: refs/heads/develop
Commit: a0c74a7ba11b41849badf8dce1ec97240fa6d05a
Parents: 585a3c6
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 17:06:17 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 17:06:17 2015 +0300

----------------------------------------------------------------------
 ...AbstractValueCompositeSerializationTest.java | 29 +++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/a0c74a7b/core/testsupport/src/main/java/org/qi4j/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/qi4j/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/qi4j/test/value/AbstractValueCompositeSerializationTest.java
index c3ed57a..01d2f51 100644
--- a/core/testsupport/src/main/java/org/qi4j/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/qi4j/test/value/AbstractValueCompositeSerializationTest.java
@@ -48,8 +48,6 @@ import org.qi4j.api.value.ValueComposite;
 import org.qi4j.api.value.ValueSerialization;
 import org.qi4j.bootstrap.AssemblyException;
 import org.qi4j.bootstrap.ModuleAssembly;
-import org.qi4j.entitystore.memory.MemoryEntityStoreService;
-import org.qi4j.spi.uuid.UuidIdentityGeneratorService;
 import org.qi4j.test.AbstractQi4jTest;
 import org.qi4j.test.EntityTestAssembler;
 
@@ -143,15 +141,9 @@ public abstract class AbstractValueCompositeSerializationTest
         specificColProto.genericList().set( genericList );
         proto.specificCollection().set( specificColBuilder.newInstance() );
 
-        /*
-         ValueBuilder<SpecificValue> specificValue = module.newValueBuilder(SpecificValue.class);
-         specificValue.prototype().item().set("Foo");
-         proto.specificValue().set(specificValue.newInstance());
-         */
-        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
-        valueBuilder.prototype().val1().set( "Foo" );
-        valueBuilder.prototypeFor( AnotherValueInternalState.class ).val2().set( "Bar" );
-        AnotherValue anotherValue = valueBuilder.newInstance();
+        AnotherValue anotherValue1 = createAnotherValue( "Foo", "Bar" );
+        AnotherValue anotherValue2 = createAnotherValue( "Habba", "ZoutZout" );
+        AnotherValue anotherValue3 = createAnotherValue( "Niclas", "Hedhman" );
 
         // FIXME Some Control Chars are not supported in JSON nor in XML, what should we do about it?
         // Should Zest Core ensure the chars used in strings are supported by the whole stack?
@@ -174,8 +166,9 @@ public abstract class AbstractValueCompositeSerializationTest
         //
         // proto.stringIntMap().get().put( "bar", 67 );
 
-        proto.stringValueMap().get().put( "foo", anotherValue );
-        proto.another().set( anotherValue );
+        proto.stringValueMap().get().put( "foo", anotherValue1 );
+        proto.another().set( anotherValue1 );
+        proto.arrayOfValues().set( new AnotherValue[] { anotherValue1, anotherValue2, anotherValue3 } );
         proto.serializable().set( new SerializableObject() );
         proto.foo().set( module.newValue( FooValue.class ) );
         proto.fooValue().set( module.newValue( FooValue.class ) );
@@ -204,6 +197,14 @@ public abstract class AbstractValueCompositeSerializationTest
         return builder.newInstance();
     }
 
+    private AnotherValue createAnotherValue( String val1, String val2 )
+    {
+        ValueBuilder<AnotherValue> valueBuilder = module.newValueBuilder( AnotherValue.class );
+        valueBuilder.prototype().val1().set( val1 );
+        valueBuilder.prototypeFor( AnotherValueInternalState.class ).val2().set( val2 );
+        return valueBuilder.newInstance();
+    }
+
     private BarEntity buildBarEntity( String cathedral )
     {
         EntityBuilder<BarEntity> barBuilder = module.currentUnitOfWork().newEntityBuilder( BarEntity.class );
@@ -253,6 +254,8 @@ public abstract class AbstractValueCompositeSerializationTest
 
         Property<AnotherValue> another();
 
+        Property<AnotherValue[]> arrayOfValues();
+
         @Optional
         Property<AnotherValue> anotherNull();
 


[6/7] zest-qi4j git commit: Merge remote-tracking branch 'origin/develop' into develop

Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/585a3c6f
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/585a3c6f
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/585a3c6f

Branch: refs/heads/develop
Commit: 585a3c6ff7b2b35d0800140ce8f13c37c963bb48
Parents: 71f5da7 858f5ba
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 16:58:23 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 16:58:23 2015 +0300

----------------------------------------------------------------------
 README.txt                                      |  3 +
 build.gradle                                    | 80 ++++++++++++++++++--
 .../org/qi4j/gradle/plugin/Documentation.groovy | 48 ++++++++++--
 libraries/lang-groovy/src/docs/lang-groovy.txt  |  2 +-
 .../src/docs/lang-javascript.txt                |  2 +-
 manual/src/docs/website/home.txt                |  6 +-
 settings.gradle                                 | 14 ++--
 7 files changed, 132 insertions(+), 23 deletions(-)
----------------------------------------------------------------------



[3/7] zest-qi4j git commit: Merge remote-tracking branch 'origin/develop' into develop

Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/279164eb
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/279164eb
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/279164eb

Branch: refs/heads/develop
Commit: 279164ebd26b001d1878df4ea539083e34e1f03f
Parents: b0225a7 21b004e
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 10:20:04 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 10:20:04 2015 +0300

----------------------------------------------------------------------
 build.gradle                                    |  57 +++++--
 buildSrc/src/javadoc/overview.html              |  23 ---
 .../org/qi4j/gradle/plugin/Documentation.groovy | 171 ++++++++++---------
 libraries/conversion/src/docs/conversion.txt    |  15 +-
 libraries/metrics/src/docs/metrics.txt          |   2 +-
 manual/build.gradle                             |   4 +-
 src/javadoc/overview.html                       |  23 +++
 7 files changed, 167 insertions(+), 128 deletions(-)
----------------------------------------------------------------------



[5/7] zest-qi4j git commit: More missing stuff for hashCode/equals of NamedAssociation.

Posted by ni...@apache.org.
More missing stuff for hashCode/equals of NamedAssociation.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/71f5da75
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/71f5da75
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/71f5da75

Branch: refs/heads/develop
Commit: 71f5da7501ff0c75612c3805557b7c5091d21fc9
Parents: 2a5405c
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 10:55:10 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 10:55:10 2015 +0300

----------------------------------------------------------------------
 .../association/NamedAssociationInstance.java   | 63 ++++++++++++++++++++
 1 file changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/71f5da75/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
index dc73b3c..c38ef1a 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/association/NamedAssociationInstance.java
@@ -22,7 +22,11 @@ import java.lang.reflect.Type;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import org.qi4j.api.association.AssociationDescriptor;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.association.ManyAssociationWrapper;
 import org.qi4j.api.association.NamedAssociation;
+import org.qi4j.api.association.NamedAssociationWrapper;
 import org.qi4j.api.entity.EntityReference;
 import org.qi4j.api.entity.Identity;
 import org.qi4j.api.util.NullArgumentException;
@@ -174,4 +178,63 @@ public class NamedAssociationInstance<T>
             }
         }, namedAssociationState );
     }
+
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        NamedAssociation<?> that = (NamedAssociation) o;
+        // Unwrap if needed
+        while( that instanceof NamedAssociationWrapper )
+        {
+            that = ( (NamedAssociationWrapper) that ).next();
+        }
+        // Descriptor equality
+        NamedAssociationInstance<?> thatInstance = (NamedAssociationInstance) that;
+        AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
+        if( !associationInfo.equals( thatDescriptor ) )
+        {
+            return false;
+        }
+        // State equality
+        if( namedAssociationState.count() != thatInstance.namedAssociationState.count() )
+        {
+            return false;
+        }
+        for( String name : namedAssociationState )
+        {
+            if( !thatInstance.namedAssociationState.containsName( name ) )
+            {
+                return false;
+            }
+            EntityReference thisReference = namedAssociationState.get( name );
+            EntityReference thatReference = thatInstance.namedAssociationState.get( name );
+            if( !thisReference.equals( thatReference ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = associationInfo.hashCode() * 31; // Descriptor
+        for( String name : namedAssociationState )
+        {
+            hash += name.hashCode();
+            hash += namedAssociationState.get( name ).hashCode() * 7; // State
+        }
+        return hash;
+    }
+
 }


[2/7] zest-qi4j git commit: And equals/hashCode is needed for the NamedAssociationValueState as well.

Posted by ni...@apache.org.
And equals/hashCode is needed for the NamedAssociationValueState as well.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/b0225a7b
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/b0225a7b
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/b0225a7b

Branch: refs/heads/develop
Commit: b0225a7b89b76c401a14c5d094779f97c84cfc7d
Parents: d2fbb10
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 08:58:43 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 08:58:43 2015 +0300

----------------------------------------------------------------------
 .../value/NamedAssociationValueState.java       | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b0225a7b/core/runtime/src/main/java/org/qi4j/runtime/value/NamedAssociationValueState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/value/NamedAssociationValueState.java b/core/runtime/src/main/java/org/qi4j/runtime/value/NamedAssociationValueState.java
index 14fcd84..694be18 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/value/NamedAssociationValueState.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/value/NamedAssociationValueState.java
@@ -82,4 +82,24 @@ public class NamedAssociationValueState
         return references.keySet().iterator();
     }
 
+    @Override
+    public boolean equals( Object o )
+    {
+        if( this == o )
+        {
+            return true;
+        }
+        if( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+        NamedAssociationValueState strings = (NamedAssociationValueState) o;
+        return references.equals( strings.references );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return references.hashCode();
+    }
 }


[4/7] zest-qi4j git commit: Introducing @Serialization annotations to mark Property methods on which variant should be used.

Posted by ni...@apache.org.
Introducing @Serialization annotations to mark Property methods on which variant should be used.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/2a5405c5
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/2a5405c5
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/2a5405c5

Branch: refs/heads/develop
Commit: 2a5405c57978b8f2d01be2c7ab3d792550a0eabc
Parents: 279164e
Author: Niclas Hedhman <he...@betfair.com>
Authored: Fri Jul 17 10:45:12 2015 +0300
Committer: Niclas Hedhman <he...@betfair.com>
Committed: Fri Jul 17 10:45:12 2015 +0300

----------------------------------------------------------------------
 .../main/java/org/qi4j/api/type/MapType.java    | 20 ++-----
 .../java/org/qi4j/api/type/Serialization.java   | 56 ++++++++++++++++++++
 .../qi4j/runtime/property/PropertyModel.java    | 23 ++++++--
 .../qi4j/runtime/types/ValueTypeFactory.java    | 23 ++++----
 .../spi/value/ValueDeserializerAdapter.java     |  5 +-
 5 files changed, 95 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/2a5405c5/core/api/src/main/java/org/qi4j/api/type/MapType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/MapType.java b/core/api/src/main/java/org/qi4j/api/type/MapType.java
index 753500a..1cb1700 100644
--- a/core/api/src/main/java/org/qi4j/api/type/MapType.java
+++ b/core/api/src/main/java/org/qi4j/api/type/MapType.java
@@ -27,17 +27,7 @@ public final class MapType
 
     private ValueType keyType;
     private ValueType valueType;
-    private final Variant variant;
-
-    /** Two Variants are made distinct.
-     * <p>
-     * The {@code entry} type represents the explicit key=keyValue, value=valueValue.
-     * </p>
-     * <p>
-     * The {@code object} type represents the explicit keyValue=valueValue.
-     * </p>
-     */
-    public enum Variant { entry, object }
+    private final Serialization.Variant variant;
 
     public static boolean isMap( Type type )
     {
@@ -50,17 +40,17 @@ public final class MapType
         return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ) );
     }
 
-    public static MapType of( Class<?> keyType, Class<?> valueType, Variant variant )
+    public static MapType of( Class<?> keyType, Class<?> valueType, Serialization.Variant variant )
     {
         return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ), variant );
     }
 
     public MapType( Class<?> type, ValueType keyType, ValueType valueType )
     {
-        this( type, keyType, valueType, Variant.entry );
+        this( type, keyType, valueType, Serialization.Variant.entry );
     }
 
-    public MapType( Class<?> type, ValueType keyType, ValueType valueType, Variant variant )
+    public MapType( Class<?> type, ValueType keyType, ValueType valueType, Serialization.Variant variant )
     {
         super( type );
         this.keyType = keyType;
@@ -82,7 +72,7 @@ public final class MapType
         return valueType;
     }
 
-    public Variant variant()
+    public Serialization.Variant variant()
     {
         return variant;
     }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/2a5405c5/core/api/src/main/java/org/qi4j/api/type/Serialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/type/Serialization.java b/core/api/src/main/java/org/qi4j/api/type/Serialization.java
new file mode 100644
index 0000000..57184a0
--- /dev/null
+++ b/core/api/src/main/java/org/qi4j/api/type/Serialization.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009, Rickard Öberg. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.qi4j.api.type;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Serialization options for Property intstances.
+ * <p>
+ * The {@code entry} type represents the explicit key=keyValue, value=valueValue. For JSON serialization;
+ * </p>
+ * <pre>
+ *     [
+ *         { "key1" : "value1" },
+ *         { "key2" : "value2" }
+ *     ]
+ * </pre>
+ * <p>
+ * For XML serialization;
+ * </p>
+ * <pre>
+ *     &lt;object&gt;
+ *         &lt;
+ *     &lt;/object&gt;
+ * </pre>
+ * <p>
+ * The {@code object} type represents the explicit keyValue=valueValue.
+ * </p>
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( { ElementType.TYPE, ElementType.METHOD } )
+@Documented
+public @interface Serialization
+{
+    Variant value();
+
+    enum Variant
+    {
+        entry, object
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/2a5405c5/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
index 235a86a..3d38927 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/property/PropertyModel.java
@@ -32,6 +32,7 @@ import org.qi4j.api.property.InvalidPropertyTypeException;
 import org.qi4j.api.property.Property;
 import org.qi4j.api.property.PropertyDescriptor;
 import org.qi4j.api.structure.Module;
+import org.qi4j.api.type.Serialization;
 import org.qi4j.api.type.ValueCompositeType;
 import org.qi4j.api.type.ValueType;
 import org.qi4j.api.util.Classes;
@@ -171,7 +172,7 @@ public class PropertyModel
         {
             if( valueType instanceof ValueCompositeType )
             {
-                return module.newValue( (Class<?>) first( valueType().types() ) );
+                return module.newValue( first( valueType().types() ) );
             }
             else
             {
@@ -189,16 +190,30 @@ public class PropertyModel
         ValueTypeFactory factory = ValueTypeFactory.instance();
         Class<?> declaringClass = ( (Member) accessor() ).getDeclaringClass();
         Class<?> mainType = first( resolution.model().types() );
-        valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module() );
-
+        Serialization.Variant variant = findVariant();
+        valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module(), variant );
         builderInfo = new BuilderPropertyInfo();
-
         if( type instanceof TypeVariable )
         {
             type = Classes.resolveTypeVariable( (TypeVariable) type, declaringClass, mainType );
         }
     }
 
+    private Serialization.Variant findVariant()
+    {
+        Serialization serialization = metaInfo.get( Serialization.class );
+        Serialization.Variant variant = null;
+        if( serialization != null )
+        {
+            variant = serialization.value();
+        }
+        if( variant == null )
+        {
+            variant = Serialization.Variant.entry;
+        }
+        return variant;
+    }
+
     @Override
     public <ThrowableType extends Throwable> boolean accept( Visitor<? super PropertyModel, ThrowableType> visitor )
         throws ThrowableType

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/2a5405c5/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java
index 0910293..9f49953 100644
--- a/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java
+++ b/core/runtime/src/main/java/org/qi4j/runtime/types/ValueTypeFactory.java
@@ -27,6 +27,7 @@ import org.qi4j.api.common.Visibility;
 import org.qi4j.api.type.CollectionType;
 import org.qi4j.api.type.EnumType;
 import org.qi4j.api.type.MapType;
+import org.qi4j.api.type.Serialization;
 import org.qi4j.api.type.ValueCompositeType;
 import org.qi4j.api.type.ValueType;
 import org.qi4j.api.util.Classes;
@@ -61,7 +62,8 @@ public class ValueTypeFactory
                                    Class declaringClass,
                                    Class compositeType,
                                    LayerModel layer,
-                                   ModuleModel module
+                                   ModuleModel module,
+                                   Serialization.Variant variant
     )
     {
         ValueType valueType = null;
@@ -76,13 +78,13 @@ public class ValueTypeFactory
                     TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
                     collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
                 }
-                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module );
+                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module, variant );
                 valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType );
             }
             else
             {
-                valueType = new CollectionType( Classes.RAW_CLASS
-                                                    .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ) );
+                ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
+                valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType );
             }
         }
         else if( MapType.isMap( type ) )
@@ -96,22 +98,21 @@ public class ValueTypeFactory
                     TypeVariable keyTypeVariable = (TypeVariable) keyType;
                     keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
                 }
-                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module );
-
+                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module, variant );
                 Type valType = pt.getActualTypeArguments()[ 1 ];
                 if( valType instanceof TypeVariable )
                 {
                     TypeVariable valueTypeVariable = (TypeVariable) valType;
                     valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
                 }
-                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module );
-
-                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyedType, valuedType );
+                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module, variant );
+                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyedType, valuedType, variant );
             }
             else
             {
-                valueType = new MapType( Classes.RAW_CLASS
-                                             .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ), newValueType( Object.class, declaringClass, compositeType, layer, module ) );
+                ValueType keyType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
+                ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
+                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyType, valuesType, variant );
             }
         }
         else if( ValueCompositeType.isValueComposite( type ) )

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/2a5405c5/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java
index b20bd79..53cf81d 100644
--- a/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/qi4j/spi/value/ValueDeserializerAdapter.java
@@ -48,6 +48,7 @@ import org.qi4j.api.type.EnumType;
 import org.qi4j.api.type.MapType;
 import org.qi4j.api.type.ValueCompositeType;
 import org.qi4j.api.type.ValueType;
+import org.qi4j.api.type.Serialization;
 import org.qi4j.api.util.Base64Encoder;
 import org.qi4j.api.util.Dates;
 import org.qi4j.api.value.ValueBuilder;
@@ -686,7 +687,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
                 Object value = getObjectFieldValue(
                     inputNode,
                     namedAssociationName,
-                    buildDeserializeInputNodeFunction( MapType.of( String.class, EntityReference.class, MapType.Variant.object ) ) );
+                    buildDeserializeInputNodeFunction( MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
                 stateMap.put( namedAssociationName, value );
             }
         }
@@ -755,7 +756,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
         if( MapType.class.isAssignableFrom( valueType.getClass() ) )
         {
             MapType mapType = (MapType) valueType;
-            if( mapType.variant().equals( MapType.Variant.entry ) )
+            if( mapType.variant().equals( Serialization.Variant.entry ) )
             {
                 return (T) deserializeNodeEntryMap( (MapType) valueType, inputNode );
             }