You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/06/27 14:26:52 UTC

[2/3] [OLINGO-317] Refactoring of 'Value-classes'

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
index 7706d93..30f4cb0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
@@ -32,6 +32,7 @@ import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
 import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@@ -71,6 +72,8 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
           new JsonDeltaDeserializer(version, false).toDelta(input);
     } catch (XMLStreamException e) {
       throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
index 12a3678..307b215 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
@@ -63,7 +63,7 @@ public class PrimitiveValueTest extends AbstractTest {
     assertEquals(Integer.valueOf(primitive), value.asPrimitive().toCastValue(Integer.class));
 
     value = getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setType(EdmPrimitiveTypeKind.Int32).setText("9").build();
+            setType(EdmPrimitiveTypeKind.Int32).setValue(9).build();
     assertEquals("9", value.asPrimitive().toCastValue(Integer.class).toString());
   }
 
@@ -75,7 +75,7 @@ public class PrimitiveValueTest extends AbstractTest {
     assertEquals(primitive, value.toString());
 
     value = getClient().getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).
-            setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
+            setValue("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
     assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().toCastValue(String.class));
   }
 
@@ -88,7 +88,7 @@ public class PrimitiveValueTest extends AbstractTest {
     assertEquals(primitive, value.asPrimitive().toCastValue(BigDecimal.class));
 
     value = getClient().getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal).
-            setText("-79228162514264337593543950335").build();
+            setValue(new BigDecimal("-79228162514264337593543950335")).build();
     assertEquals("-79228162514264337593543950335", value.asPrimitive().toCastValue(BigDecimal.class).toString());
   }
 
@@ -121,15 +121,15 @@ public class PrimitiveValueTest extends AbstractTest {
 
   @Test
   public void time() throws EdmPrimitiveTypeException {
-    final String primitive = "-P9DT51M10.5063807S";
     final ODataValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setType(EdmPrimitiveTypeKind.Time).setText(primitive).build();
+            setType(EdmPrimitiveTypeKind.Time).setValue(BigDecimal.valueOf(-780670.5063807)).build();
     assertEquals(EdmPrimitiveTypeKind.Time, value.asPrimitive().getTypeKind());
     assertEquals(BigDecimal.valueOf(-780670.5063807), value.asPrimitive().toCastValue(BigDecimal.class));
+    assertEquals("-P9DT51M10.5063807S", value.asPrimitive().toString());
 
     final ODataPrimitiveValue write = getClient().getObjectFactory().newPrimitiveValueBuilder().
             setType(EdmPrimitiveTypeKind.Time).setValue(BigDecimal.valueOf(-780670.5063807)).build();
-    assertEquals(primitive, write.toString());
+    assertEquals("-P9DT51M10.5063807S", write.toString());
   }
 
   @Test
@@ -159,7 +159,7 @@ public class PrimitiveValueTest extends AbstractTest {
     assertEquals("2013-01-10T02:00:00.022Z", value.asPrimitive().toString());
 
     final ODataValue parsed = getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setType(EdmPrimitiveTypeKind.DateTimeOffset).setText(value.asPrimitive().toString()).build();
+            setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(value.asPrimitive().toValue()).build();
     assertEquals(22, parsed.asPrimitive().toCastValue(Calendar.class).get(Calendar.MILLISECOND));
   }
 
@@ -172,7 +172,7 @@ public class PrimitiveValueTest extends AbstractTest {
     assertEquals(primitive, value.asPrimitive().toCastValue(UUID.class));
 
     value = getClient().getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).
-            setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
+            setValue(UUID.fromString("1126a28b-a4af-4bbd-bf0a-2b2c22635565")).build();
     assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().toCastValue(UUID.class).toString());
   }
 
@@ -187,8 +187,7 @@ public class PrimitiveValueTest extends AbstractTest {
             Base64.encodeBase64String(value.asPrimitive().toCastValue(byte[].class)));
 
     value = getClient().getObjectFactory().newPrimitiveValueBuilder().
-            setType(EdmPrimitiveTypeKind.Binary).
-            setText(Base64.encodeBase64String("primitive".getBytes())).build();
+            setType(EdmPrimitiveTypeKind.Binary).setValue("primitive".getBytes()).build();
     assertEquals("primitive", new String(value.asPrimitive().toCastValue(byte[].class)));
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
index 99c000a..5f5f55b 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PropertyTest.java
@@ -54,7 +54,7 @@ public class PropertyTest extends AbstractTest {
 
     final ODataPrimitiveValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
             setType(EdmPrimitiveTypeKind.String).
-            setText(IOUtils.toString(input)).
+            setValue(IOUtils.toString(input)).
             build();
     assertNotNull(value);
     assertEquals("-10", value.toString());
@@ -77,7 +77,7 @@ public class PropertyTest extends AbstractTest {
       // This is needed because type information gets lost with JSON serialization
       final ODataPrimitiveValue typedValue = getClient().getObjectFactory().newPrimitiveValueBuilder().
               setType(property.getPrimitiveValue().getTypeKind()).
-              setText(written.getPrimitiveValue().toString()).
+              setValue(written.getPrimitiveValue().toValue()).
               build();
       comparable = getClient().getObjectFactory().newPrimitiveProperty(written.getName(), typedValue);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
index 1c96534..4cfae6f 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -213,10 +213,10 @@ public class JSONTest extends AbstractTest {
     assertEquals(2, delta.getEntities().size());
     Property property = delta.getEntities().get(0).getProperty("ContactName");
     assertNotNull(property);
-    assertTrue(property.getValue().isPrimitive());
+    assertTrue(property.isPrimitive());
     property = delta.getEntities().get(1).getProperty("ShippingAddress");
     assertNotNull(property);
-    assertTrue(property.getValue().isComplex());
+    assertTrue(property.isLinkedComplex());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
index db12081..c66f15d 100644
--- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/entity.primitive.json
@@ -16,7 +16,7 @@
   "Int64Value": 0,
   "ColorEnumValue": "Yellow",
   "GeographyPoint": {
-    "type": "point",
+    "type": "Point",
     "coordinates": [142.1, 64.1]
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/CollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/CollectionValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/CollectionValue.java
deleted file mode 100644
index 0d55671..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/CollectionValue.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-import java.util.List;
-
-public interface CollectionValue extends Value {
-
-  @Override
-  List<Value> get();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
deleted file mode 100644
index 67a2f04..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-import java.util.List;
-
-public interface ComplexValue extends Value {
-
-  @Override
-  List<Property> get();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
deleted file mode 100644
index 2f13fa7..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EnumValue.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-public interface EnumValue extends Value {
-
-  @Override
-  String get();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/GeospatialValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/GeospatialValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/GeospatialValue.java
deleted file mode 100644
index 08dcf4b..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/GeospatialValue.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-
-public interface GeospatialValue extends Value {
-
-  @Override
-  Geospatial get();
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
index 057a535..bc7e8cb 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.commons.api.data;
 
-public interface LinkedComplexValue extends ComplexValue, Linked, Annotatable {
+import java.util.List;
 
+public interface LinkedComplexValue extends Linked, Annotatable {
+
+  List<Property> getValue();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/NullValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/NullValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/NullValue.java
deleted file mode 100644
index 2fed975..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/NullValue.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-public interface NullValue extends Value {
-
-  @Override
-  Void get();
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/PrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/PrimitiveValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/PrimitiveValue.java
deleted file mode 100644
index dabbc47..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/PrimitiveValue.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-public interface PrimitiveValue extends Value {
-
-  @Override
-  String get();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
index 11a4bf0..e2a728b 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
@@ -18,13 +18,32 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.List;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+
 public interface Valuable {
 
   String getType();
-
   void setType(String type);
 
-  Value getValue();
+  boolean isNull();
+  boolean isPrimitive();
+  boolean isGeospatial();
+  boolean isEnum();
+  boolean isComplex();
+  boolean isLinkedComplex();
+  boolean isCollection();
+
+  Object getValue();
+
+  Object asPrimitive();
+  Object asEnum();
+  Geospatial asGeospatial();
+  List<Property> asComplex();
+  LinkedComplexValue asLinkedComplex();
+  List<?> asCollection();
 
-  void setValue(Value value);
+  void setValue(ValueType valuetype, Object value);
+  ValueType getValueType();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
deleted file mode 100644
index 268a026..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Value.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.api.data;
-
-public interface Value {
-
-  boolean isNull();
-
-  boolean isPrimitive();
-
-  boolean isGeospatial();
-
-  boolean isEnum();
-
-  boolean isComplex();
-
-  boolean isLinkedComplex();
-
-  boolean isCollection();
-
-  Object get();
-
-  PrimitiveValue asPrimitive();
-
-  EnumValue asEnum();
-
-  GeospatialValue asGeospatial();
-
-  ComplexValue asComplex();
-
-  LinkedComplexValue asLinkedComplex();
-
-  CollectionValue asCollection();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
new file mode 100644
index 0000000..2ce9a17
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ValueType.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.olingo.commons.api.data;
+
+public enum ValueType {
+  PRIMITIVE, GEOSPATIAL, ENUM, COMPLEX, LINKED_COMPLEX,
+  COLLECTION_PRIMITIVE(PRIMITIVE),
+  COLLECTION_GEOSPATIAL(GEOSPATIAL),
+  COLLECTION_ENUM(ENUM),
+  COLLECTION_COMPLEX(COMPLEX),
+  COLLECTION_LINKED_COMPLEX(LINKED_COMPLEX);
+
+  private final ValueType baseType;
+
+  private ValueType() {
+    baseType = this;
+  }
+
+  private ValueType(ValueType baseType) {
+    this.baseType = baseType;
+  }
+
+  public ValueType getBaseType() {
+    return baseType;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
index 7e9d054..8494411 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
@@ -32,8 +32,6 @@ public interface ODataPrimitiveValue extends ODataValue {
 
     Builder setType(EdmPrimitiveTypeKind type);
 
-    Builder setText(String text);
-
     Builder setValue(Object value);
 
     ODataPrimitiveValue build();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
new file mode 100644
index 0000000..43d512b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.olingo.commons.core.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+
+public abstract class AbstractValuable implements Valuable, Annotatable {
+
+  private ValueType valueType = null;
+  private Object value = null;
+  private final List<Annotation> annotations = new ArrayList<Annotation>();
+
+  @Override
+  public boolean isNull() {
+    return value == null;
+  }
+
+  @Override
+  public boolean isPrimitive() {
+    return valueType == ValueType.PRIMITIVE;
+  }
+
+  @Override
+  public boolean isGeospatial() {
+    return valueType == ValueType.GEOSPATIAL;
+  }
+
+  @Override
+  public boolean isEnum() {
+    return valueType == ValueType.ENUM;
+  }
+
+  @Override
+  public boolean isComplex() {
+    return valueType == ValueType.COMPLEX;
+  }
+
+  @Override
+  public boolean isLinkedComplex() {
+    return valueType == ValueType.LINKED_COMPLEX;
+  }
+
+  @Override
+  public boolean isCollection() {
+    return valueType != null && valueType != valueType.getBaseType();
+  }
+
+  @Override
+  public Object asPrimitive() {
+    return isPrimitive() ? value : null;
+  }
+
+  @Override
+  public Geospatial asGeospatial() {
+    return isGeospatial() ? (Geospatial) value : null;
+  }
+
+  @Override
+  public Object asEnum() {
+    return isEnum() ? value : null;
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public List<Property> asComplex() {
+    return isComplex() ? (List<Property>) value : null;
+  }
+
+  @Override
+  public LinkedComplexValue asLinkedComplex() {
+    return isLinkedComplex() ? (LinkedComplexValue) value : null;
+  }
+
+  @Override
+  public List<?> asCollection() {
+    return isCollection() ? (List<?>) value : null;
+  }
+
+  @Override
+  public Object getValue() {
+    return value;
+  }
+
+  @Override
+  public void setValue(final ValueType valueType, final Object value) {
+    this.valueType = valueType;
+    this.value  = value;
+  }
+
+  @Override
+  public ValueType getValueType() {
+    return valueType;
+  }
+
+  @Override
+  public List<Annotation> getAnnotations() {
+    return annotations;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
deleted file mode 100644
index 79566bb..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValue.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.EnumValue;
-import org.apache.olingo.commons.api.data.GeospatialValue;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.NullValue;
-import org.apache.olingo.commons.api.data.PrimitiveValue;
-import org.apache.olingo.commons.api.data.Value;
-
-public abstract class AbstractValue implements Value {
-
-  @Override
-  public boolean isNull() {
-    return false;
-  }
-
-  @Override
-  public boolean isPrimitive() {
-    return false;
-  }
-
-  @Override
-  public boolean isGeospatial() {
-    return false;
-  }
-
-  @Override
-  public boolean isEnum() {
-    return false;
-  }
-
-  @Override
-  public boolean isComplex() {
-    return false;
-  }
-
-  @Override
-  public boolean isLinkedComplex() {
-    return false;
-  }
-
-  @Override
-  public boolean isCollection() {
-    return false;
-  }
-
-  @Override
-  public PrimitiveValue asPrimitive() {
-    return isPrimitive() ? (PrimitiveValue) this : null;
-  }
-
-  @Override
-  public GeospatialValue asGeospatial() {
-    return isGeospatial() ? (GeospatialValue) this : null;
-  }
-
-  @Override
-  public EnumValue asEnum() {
-    return isEnum() ? (EnumValue) this : null;
-  }
-
-  @Override
-  public ComplexValue asComplex() {
-    return isComplex() ? (ComplexValue) this : null;
-  }
-
-  @Override
-  public LinkedComplexValue asLinkedComplex() {
-    return isLinkedComplex() ? (LinkedComplexValue) this : null;
-  }
-
-  @Override
-  public CollectionValue asCollection() {
-    return isCollection() ? (CollectionValue) this : null;
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
index 626c00e..845a2a2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
@@ -19,13 +19,11 @@
 package org.apache.olingo.commons.core.data;
 
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Value;
 
-public class AnnotationImpl extends AbstractAnnotatedObject implements Annotation {
+public class AnnotationImpl extends AbstractValuable implements Annotation {
 
   private String term;
   private String type;
-  private Value value;
 
   @Override
   public String getTerm() {
@@ -46,14 +44,4 @@ public class AnnotationImpl extends AbstractAnnotatedObject implements Annotatio
   public void setType(final String type) {
     this.type = type;
   }
-
-  @Override
-  public Value getValue() {
-    return value;
-  }
-
-  @Override
-  public void setValue(final Value value) {
-    this.value = value;
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/CollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/CollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/CollectionValueImpl.java
deleted file mode 100644
index 02c6d43..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/CollectionValueImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.CollectionValue;
-import org.apache.olingo.commons.api.data.Value;
-
-public class CollectionValueImpl extends AbstractValue implements CollectionValue {
-
-  private final List<Value> value = new ArrayList<Value>();
-
-  @Override
-  public boolean isCollection() {
-    return true;
-  }
-
-  @Override
-  public List<Value> get() {
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
deleted file mode 100644
index 0144f83..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-
-public class ComplexValueImpl extends AbstractValue implements ComplexValue {
-
-  private final List<Property> value = new ArrayList<Property>();
-
-  @Override
-  public boolean isComplex() {
-    return true;
-  }
-
-  @Override
-  public List<Property> get() {
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java
deleted file mode 100644
index 5d79d22..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EnumValueImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.EnumValue;
-
-public class EnumValueImpl extends AbstractValue implements EnumValue {
-
-  private final String value;
-
-  public EnumValueImpl(final String value) {
-    this.value = value;
-  }
-
-  @Override
-  public boolean isEnum() {
-    return true;
-  }
-
-  @Override
-  public String get() {
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/GeospatialValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/GeospatialValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/GeospatialValueImpl.java
deleted file mode 100644
index e278334..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/GeospatialValueImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.GeospatialValue;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-
-public class GeospatialValueImpl extends AbstractValue implements GeospatialValue {
-
-  private final Geospatial value;
-
-  public GeospatialValueImpl(final Geospatial value) {
-    this.value = value;
-  }
-
-  @Override
-  public boolean isGeospatial() {
-    return true;
-  }
-
-  @Override
-  public Geospatial get() {
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java
index d37741a..d9d6af7 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java
@@ -20,21 +20,22 @@ package org.apache.olingo.commons.core.data;
 
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.Property;
 
-public class LinkedComplexValueImpl extends ComplexValueImpl implements LinkedComplexValue {
+public class LinkedComplexValueImpl implements LinkedComplexValue {
 
+  private final List<Property> value = new ArrayList<Property>();
   private final List<Link> associationLinks = new ArrayList<Link>();
-
   private final List<Link> navigationLinks = new ArrayList<Link>();
-
   private final List<Annotation> annotations = new ArrayList<Annotation>();
 
   @Override
-  public boolean isLinkedComplex() {
-    return true;
+  public List<Property> getValue() {
+    return value;
   }
 
   private Link getOneByTitle(final String name, final List<Link> links) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
deleted file mode 100644
index 1fca329..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.NullValue;
-
-public class NullValueImpl extends AbstractValue implements NullValue {
-
-  @Override
-  public boolean isNull() {
-    return true;
-  }
-
-  @Override
-  public Void get() {
-    return null;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
deleted file mode 100644
index b3334ae..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.apache.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.PrimitiveValue;
-
-public class PrimitiveValueImpl extends AbstractValue implements PrimitiveValue {
-
-  private final String value;
-
-  public PrimitiveValueImpl(final String value) {
-    this.value = value;
-  }
-
-  @Override
-  public boolean isPrimitive() {
-    return true;
-  }
-
-  @Override
-  public String get() {
-    return value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
index f98e854..4220506 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -19,13 +19,11 @@
 package org.apache.olingo.commons.core.data;
 
 import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.Value;
 
-public class PropertyImpl extends AbstractAnnotatedObject implements Property {
+public class PropertyImpl extends AbstractValuable implements Property {
 
   private String name;
   private String type;
-  private Value value;
 
   @Override
   public String getName() {
@@ -48,12 +46,7 @@ public class PropertyImpl extends AbstractAnnotatedObject implements Property {
   }
 
   @Override
-  public Value getValue() {
-    return value;
-  }
-
-  @Override
-  public void setValue(final Value value) {
-    this.value = value;
+  public boolean isNull() {
+    return getValue() == null || "Edm.Null".equals(type);  // TODO: improve
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
index 844c69a..484d643 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataPrimitiveValue.java
@@ -18,9 +18,8 @@
  */
 package org.apache.olingo.commons.core.domain;
 
-import java.sql.Timestamp;
-import java.util.Calendar;
 import java.util.UUID;
+
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.domain.AbstractODataValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
@@ -83,12 +82,6 @@ public abstract class AbstractODataPrimitiveValue extends AbstractODataValue imp
     }
 
     @Override
-    public AbstractBuilder setText(final String text) {
-      getInstance().text = text;
-      return this;
-    }
-
-    @Override
     public AbstractBuilder setValue(final Object value) {
       getInstance().value = value;
       return this;
@@ -96,39 +89,9 @@ public abstract class AbstractODataPrimitiveValue extends AbstractODataValue imp
 
     @Override
     public ODataPrimitiveValue build() {
-      if (getInstance().text == null && getInstance().value == null) {
-        throw new IllegalArgumentException("Must provide either text or value");
-      }
-      if (getInstance().text != null && getInstance().value != null) {
-        throw new IllegalArgumentException("Cannot provide both text and value");
-      }
-
       if (getInstance().type == null) {
         setType(EdmPrimitiveTypeKind.String);
       }
-
-      if (getInstance().text != null) {
-        final Class<?> returnType = getInstance().type.getDefaultType().isAssignableFrom(Calendar.class)
-                ? Timestamp.class : getInstance().type.getDefaultType();
-        try {
-          // TODO: when Edm is available, set facets when calling this method
-          getInstance().value = getInstance().type.valueOfString(
-                  getInstance().text, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
-                  returnType);
-        } catch (EdmPrimitiveTypeException e) {
-          throw new IllegalArgumentException(e);
-        }
-      }
-      if (getInstance().value != null) {
-        try {
-          // TODO: when Edm is available, set facets when calling this method
-          getInstance().text = getInstance().type.valueToString(
-                  getInstance().value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
-        } catch (EdmPrimitiveTypeException e) {
-          throw new IllegalArgumentException(e);
-        }
-      }
-
       return getInstance();
     }
 
@@ -190,11 +153,6 @@ public abstract class AbstractODataPrimitiveValue extends AbstractODataValue imp
   private EdmPrimitiveType type;
 
   /**
-   * Text value.
-   */
-  private String text;
-
-  /**
    * Actual value.
    */
   private Object value;
@@ -225,16 +183,36 @@ public abstract class AbstractODataPrimitiveValue extends AbstractODataValue imp
 
   @Override
   public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
-    return typeKind.isGeospatial()
-            ? reference.cast(this.value)
-            // TODO: when Edm is available, set facets when calling this method
-            : type.valueOfString(this.text,
-                    null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
+    if (value == null) {
+      return null;
+    } else if (typeKind.isGeospatial()) {
+      return reference.cast(value);
+    } else {
+      try {
+        // TODO: when Edm is available, set facets when calling this method
+        return type.valueOfString(type.valueToString(value,
+            null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null),
+            null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
+      } catch (EdmPrimitiveTypeException e) {
+        throw new IllegalArgumentException(e);
+      }
+    }
   }
 
   @Override
   public String toString() {
-    return this.text;
+    if (value == null) {
+      return "";
+    } else if (typeKind.isGeospatial()) {
+      return value.toString();
+    } else {
+      try {
+        // TODO: when Edm is available, set facets when calling this method
+        return type.valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+      } catch (EdmPrimitiveTypeException e) {
+        throw new IllegalArgumentException(e);
+      }
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
index e2e2036..3643ba3 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
@@ -78,7 +78,7 @@ public abstract class AbstractODataProperty implements CommonODataProperty {
    */
   @Override
   public boolean hasNullValue() {
-    return this.value == null;
+    return this.value == null || value.isPrimitive() && value.asPrimitive().toValue() == null;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
index 9aa660e..9227dbd 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
@@ -62,7 +62,7 @@ public final class EdmDate extends SingletonPrimitiveType {
             Byte.parseByte(matcher.group(3)));
 
     try {
-      return EdmDateTimeOffset.convertDateTime(dateTimeValue, returnType);
+      return EdmDateTimeOffset.convertDateTime(dateTimeValue, 0, returnType);
     } catch (final IllegalArgumentException e) {
       throw new EdmPrimitiveTypeException(
               "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
index c8c8eb5..f5d3a6e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.commons.core.edm.primitivetype;
 
 import java.sql.Timestamp;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -46,7 +47,7 @@ public final class EdmDateTime extends SingletonPrimitiveType {
 
   @Override
   public Class<?> getDefaultType() {
-    return Calendar.class;
+    return Timestamp.class;
   }
 
   @Override
@@ -59,7 +60,7 @@ public final class EdmDateTime extends SingletonPrimitiveType {
     final Date date;
     try {
       date = DATE_FORMAT.get().parse(dateParts[0]);
-    } catch (Exception e) {
+    } catch (ParseException e) {
       throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
     }
 
@@ -93,9 +94,9 @@ public final class EdmDateTime extends SingletonPrimitiveType {
       calendar.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
 
       if (!decimals.isEmpty()) {
-        final int fractionalSecs = calendar.get(Calendar.MILLISECOND);
-        // if fractional are just milliseconds, convert to nanoseconds
-        timestamp.setNanos(fractionalSecs < 1000 ? fractionalSecs * 1000000 : fractionalSecs);
+        final int nanos = Integer.parseInt(decimals.length() > 9 ? decimals.substring(0, 9) :
+            decimals + "000000000".substring(decimals.length()));
+        timestamp.setNanos(nanos);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
index 3f1d27a..12bb794 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
@@ -53,7 +53,7 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
 
   @Override
   public Class<?> getDefaultType() {
-    return Calendar.class;
+    return Timestamp.class;
   }
 
   @Override
@@ -83,10 +83,7 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
             Byte.parseByte(matcher.group(5)),
             matcher.group(6) == null ? 0 : Byte.parseByte(matcher.group(6)));
 
-    // cloning the original Calendar instance to avoid vanishing the Calendar value check - triggered by any
-    // get method - empowered by the convertDateTime() method below
-    final Timestamp timestamp = new Timestamp(((Calendar) dateTimeValue.clone()).getTimeInMillis());
-
+    int nanoSeconds = 0;
     if (matcher.group(7) != null) {
       if (matcher.group(7).length() == 1 || matcher.group(7).length() > 13) {
         throw new EdmPrimitiveTypeException(
@@ -97,24 +94,21 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
         throw new EdmPrimitiveTypeException(
                 "EdmPrimitiveTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets)");
       }
-      final String milliSeconds = decimals.length() > 3
-              ? decimals.substring(0, 3)
-              : decimals + "000".substring(decimals.length());
-      dateTimeValue.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
-
-      if (!decimals.isEmpty()) {
-        final int fractionalSecs = dateTimeValue.get(Calendar.MILLISECOND);
-        // if fractional are just milliseconds, convert to nanoseconds
-        timestamp.setNanos(fractionalSecs < 1000 ? fractionalSecs * 1000000 : fractionalSecs);
+      if (returnType.isAssignableFrom(Timestamp.class)) {
+        if (!decimals.isEmpty()) {
+          nanoSeconds = Integer.parseInt(decimals.length() > 9 ? decimals.substring(0, 9) :
+              decimals + "000000000".substring(decimals.length()));
+        }
+      } else {
+        final String milliSeconds = decimals.length() > 3 ?
+            decimals.substring(0, 3) :
+            decimals + "000".substring(decimals.length());
+        dateTimeValue.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
       }
     }
 
-    if (returnType.isAssignableFrom(Timestamp.class)) {
-      return returnType.cast(timestamp);
-    }
-
     try {
-      return convertDateTime(dateTimeValue, returnType);
+      return convertDateTime(dateTimeValue, nanoSeconds, returnType);
     } catch (final IllegalArgumentException e) {
       throw new EdmPrimitiveTypeException(
               "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
@@ -128,14 +122,15 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
    * Converts a {@link Calendar} value into the requested return type if possible.
    *
    * @param dateTimeValue the value
-   * @param returnType the class of the returned value; it must be one of {@link Calendar}, {@link Long}, or
-   * {@link Date}
+   * @param nanoSeconds   nanoseconds part of the value; only used for the {@link Timestamp} return type
+   * @param returnType    the class of the returned value;
+   *                      it must be one of {@link Calendar}, {@link Long}, {@link Date}, or {@link Timestamp}
    * @return the converted value
    * @throws IllegalArgumentException if the Calendar value is not valid
    * @throws ClassCastException if the return type is not allowed
    */
-  protected static <T> T convertDateTime(final Calendar dateTimeValue, final Class<T> returnType)
-          throws IllegalArgumentException, ClassCastException {
+  protected static <T> T convertDateTime(final Calendar dateTimeValue, final int nanoSeconds,
+      final Class<T> returnType) throws IllegalArgumentException, ClassCastException {
 
     // The Calendar class does not check any values until a get method is called,
     // so we do just that to validate the fields that may have been set,
@@ -154,7 +149,9 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
     } else if (returnType.isAssignableFrom(Date.class)) {
       return returnType.cast(dateTimeValue.getTime()); // may throw IllegalArgumentException
     } else if (returnType.isAssignableFrom(Timestamp.class)) {
-      return returnType.cast(new Timestamp(dateTimeValue.getTimeInMillis()));
+      Timestamp timestamp = new Timestamp(dateTimeValue.getTimeInMillis());
+      timestamp.setNanos(nanoSeconds);
+      return returnType.cast(timestamp);
     } else {
       throw new ClassCastException("unsupported return type " + returnType.getSimpleName());
     }
@@ -168,7 +165,7 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
     final Calendar dateTimeValue;
     final int fractionalSecs;
     if (value instanceof Timestamp) {
-      final Calendar tmp = Calendar.getInstance();
+      final Calendar tmp = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
       tmp.setTimeInMillis(((Timestamp) value).getTime());
       dateTimeValue = createDateTime(tmp);
       fractionalSecs = ((Timestamp) value).getNanos();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
index 2003b09..32a0533 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
@@ -58,10 +58,7 @@ public final class EdmTimeOfDay extends SingletonPrimitiveType {
     dateTimeValue.set(Calendar.MINUTE, Byte.parseByte(matcher.group(2)));
     dateTimeValue.set(Calendar.SECOND, matcher.group(3) == null ? 0 : Byte.parseByte(matcher.group(3)));
 
-    // cloning the original Calendar instance to avoid vanishing the Calendar value check - triggered by any
-    // get method - empowered by the convertDateTime() method below
-    final Timestamp timestamp = new Timestamp(((Calendar) dateTimeValue.clone()).getTimeInMillis());
-
+    int nanoSeconds = 0;
     if (matcher.group(4) != null) {
       if (matcher.group(4).length() == 1 || matcher.group(4).length() > 13) {
         throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
@@ -71,22 +68,19 @@ public final class EdmTimeOfDay extends SingletonPrimitiveType {
         throw new EdmPrimitiveTypeException(
                 "EdmPrimitiveTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets)");
       }
-      final String milliSeconds = decimals.length() > 3
-                                  ? decimals.substring(0, 3)
-                                  : decimals + "000".substring(decimals.length());
-      dateTimeValue.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
-
-      if (!decimals.isEmpty()) {
-        timestamp.setNanos(Integer.parseInt(decimals));
+      final String milliSeconds = decimals.length() > 3 ?
+          decimals.substring(0, 3) :
+          decimals + "000".substring(decimals.length());
+      final short millis = Short.parseShort(milliSeconds);
+      if (returnType.isAssignableFrom(Timestamp.class)) {
+        nanoSeconds = millis * 1000 * 1000;
+      } else {
+        dateTimeValue.set(Calendar.MILLISECOND, millis);
       }
     }
 
-    if (returnType.isAssignableFrom(Timestamp.class)) {
-      return returnType.cast(timestamp);
-    }
-
     try {
-      return EdmDateTimeOffset.convertDateTime(dateTimeValue, returnType);
+      return EdmDateTimeOffset.convertDateTime(dateTimeValue, nanoSeconds, returnType);
     } catch (final IllegalArgumentException e) {
       throw new EdmPrimitiveTypeException(
               "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a2874142/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index 9168b89..11aaa35 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -37,39 +37,36 @@ import javax.xml.stream.events.XMLEvent;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.CollectionValue;
 import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.data.v3.LinkCollection;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.serialization.ODataDeserializer;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.data.AbstractODataObject;
 import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.CollectionValueImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.DeletedEntityImpl;
 import org.apache.olingo.commons.core.data.DeltaLinkImpl;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.EnumValueImpl;
-import org.apache.olingo.commons.core.data.GeospatialValueImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
-import org.apache.olingo.commons.core.data.NullValueImpl;
 import org.apache.olingo.commons.core.data.ODataErrorImpl;
-import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
 import org.apache.olingo.commons.core.data.v4.DeltaImpl;
@@ -92,10 +89,10 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     this.geoDeserializer = new AtomGeoValueDeserializer();
   }
 
-  private Value fromPrimitive(final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException {
+  private Object fromPrimitive(final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
 
-    Value value = null;
+    Object value = null;
 
     boolean foundEndProperty = false;
     while (reader.hasNext() && !foundEndProperty) {
@@ -104,13 +101,17 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
         final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(
             version, typeInfo.getFullQualifiedName().toString());
-        value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
+        value = geoDeserializer.deserialize(reader, event.asStartElement(), geoType);
       }
 
       if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
           && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
 
-        value = new PrimitiveValueImpl(event.asCharacters().getData());
+        final String stringValue = event.asCharacters().getData();
+        value = typeInfo == null ? stringValue :  // TODO: add facets
+            ((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
+                Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
+                ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
       }
 
       if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -118,13 +119,13 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       }
     }
 
-    return value == null ? new PrimitiveValueImpl(StringUtils.EMPTY) : value;
+    return value;
   }
 
-  private Value fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
+  private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
-    Value value = null;
+    Object value = null;
 
     boolean foundEndProperty = false;
     while (reader.hasNext() && !foundEndProperty) {
@@ -132,9 +133,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
       if (event.isStartElement()) {
         if (value == null) {
-          value = version.compareTo(ODataServiceVersion.V40) < 0
-              ? new ComplexValueImpl()
-              : new LinkedComplexValueImpl();
+          value = version.compareTo(ODataServiceVersion.V40) < 0 ?
+              new ArrayList<Property>() : new LinkedComplexValueImpl();
         }
 
         if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
@@ -159,20 +159,21 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
           if (link.getRel().startsWith(
               version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) {
 
-            value.asLinkedComplex().getNavigationLinks().add(link);
+            ((LinkedComplexValue) value).getNavigationLinks().add(link);
             inline(reader, event.asStartElement(), link);
           } else if (link.getRel().startsWith(
               version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL))) {
 
-            value.asLinkedComplex().getAssociationLinks().add(link);
+            ((Valuable) value).asLinkedComplex().getAssociationLinks().add(link);
           }
         } else {
-          value.asComplex().get().add(property(reader, event.asStartElement()));
+          (value instanceof LinkedComplexValue ? ((LinkedComplexValue) value).getValue() : (List<Property>) value)
+              .add(property(reader, event.asStartElement()));
         }
       }
 
       if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
-        value = new EnumValueImpl(event.asCharacters().getData());
+        value = event.asCharacters().getData();
       }
 
       if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@@ -183,14 +184,14 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return value;
   }
 
-  private CollectionValue fromCollection(final XMLEventReader reader, final StartElement start,
-      final EdmTypeInfo typeInfo) throws XMLStreamException {
+  private void fromCollection(Valuable valuable, final XMLEventReader reader, final StartElement start,
+      final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {
 
-    final CollectionValueImpl value = new CollectionValueImpl();
+    List<Object> values = new ArrayList<Object>();
+    ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
 
-    final EdmTypeInfo type = typeInfo == null
-        ? null
-        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+    final EdmTypeInfo type = typeInfo == null ? null :
+        new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
 
     boolean foundEndProperty = false;
     while (reader.hasNext() && !foundEndProperty) {
@@ -199,12 +200,22 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       if (event.isStartElement()) {
         switch (guessPropertyType(reader, typeInfo)) {
         case COMPLEX:
+          final Object complexValue = fromComplexOrEnum(reader, event.asStartElement());
+          valueType = complexValue instanceof LinkedComplexValue ?
+              ValueType.COLLECTION_LINKED_COMPLEX : ValueType.COLLECTION_COMPLEX;
+          values.add(complexValue);
+          break;
+
         case ENUM:
-          value.get().add(fromComplexOrEnum(reader, event.asStartElement()));
+          valueType = ValueType.COLLECTION_ENUM;
+          values.add(fromComplexOrEnum(reader, event.asStartElement()));
           break;
 
         case PRIMITIVE:
-          value.get().add(fromPrimitive(reader, event.asStartElement(), type));
+          final Object value = fromPrimitive(reader, event.asStartElement(), type);
+          valueType = value instanceof Geospatial ?
+              ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
+          values.add(value);
           break;
 
         default:
@@ -216,8 +227,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
         foundEndProperty = true;
       }
     }
-
-    return value;
+    valuable.setValue(valueType, values);
   }
 
   private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo)
@@ -235,9 +245,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
     final ODataPropertyType type;
     if (child == null) {
-      type = typeInfo == null || typeInfo.isPrimitiveType()
-          ? ODataPropertyType.PRIMITIVE
-          : ODataPropertyType.ENUM;
+      type = typeInfo == null || typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.ENUM;
     } else {
       if (child.isStartElement()) {
         if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) {
@@ -260,7 +268,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   private Property property(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
     final PropertyImpl property = new PropertyImpl();
 
@@ -279,39 +287,36 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return property;
   }
 
-  private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
+  private void valuable(Valuable valuable, final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
     final Attribute nullAttr = start.getAttributeByName(this.nullQName);
 
-    Value value;
-    if (nullAttr == null) {
-      final Attribute typeAttr = start.getAttributeByName(this.typeQName);
-      final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
+    final Attribute typeAttr = start.getAttributeByName(this.typeQName);
+    final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue();
 
-      final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue)
-          ? null
-          : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
+    final EdmTypeInfo typeInfo = StringUtils.isBlank(typeAttrValue) ? null :
+        new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build();
 
-      if (typeInfo != null) {
-        valuable.setType(typeInfo.internal());
-      }
+    if (typeInfo != null) {
+      valuable.setType(typeInfo.internal());
+    }
 
-      final ODataPropertyType propType = typeInfo == null
-          ? guessPropertyType(reader, typeInfo)
-          : typeInfo.isCollection()
-              ? ODataPropertyType.COLLECTION
-              : typeInfo.isPrimitiveType()
-                  ? ODataPropertyType.PRIMITIVE
-                  : ODataPropertyType.COMPLEX;
+    final ODataPropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) :
+        typeInfo.isCollection() ? ODataPropertyType.COLLECTION :
+            typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.COMPLEX;
 
+    if (nullAttr == null) {
       switch (propType) {
       case COLLECTION:
-        value = fromCollection(reader, start, typeInfo);
+        fromCollection(valuable, reader, start, typeInfo);
         break;
 
       case COMPLEX:
-        value = fromComplexOrEnum(reader, start);
+        final Object complexValue = fromComplexOrEnum(reader, start);
+        valuable.setValue(complexValue instanceof LinkedComplexValue ? ValueType.LINKED_COMPLEX :
+            complexValue instanceof List<?> ? ValueType.COMPLEX : ValueType.ENUM,
+            complexValue);
         break;
 
       case PRIMITIVE:
@@ -319,18 +324,21 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
         if (typeInfo == null) {
           valuable.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString());
         }
-        value = fromPrimitive(reader, start, typeInfo);
+        final Object value = fromPrimitive(reader, start, typeInfo);
+        valuable.setValue(value instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, value);
         break;
 
       case EMPTY:
       default:
-        value = new PrimitiveValueImpl(StringUtils.EMPTY);
+        valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
       }
     } else {
-      value = new NullValueImpl();
+      valuable.setValue(propType == ODataPropertyType.PRIMITIVE ? ValueType.PRIMITIVE :
+        propType == ODataPropertyType.ENUM ? ValueType.ENUM :
+        propType == ODataPropertyType.COMPLEX ? ValueType.COMPLEX :
+        propType == ODataPropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE,
+        null);
     }
-
-    valuable.setValue(value);
   }
 
   @Override
@@ -341,6 +349,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       return getContainer(start, property(reader, start));
     } catch (XMLStreamException e) {
       throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
     }
   }
 
@@ -381,7 +391,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
-      throws XMLStreamException {
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
     boolean foundEndElement = false;
     while (reader.hasNext() && !foundEndElement) {
@@ -417,13 +427,15 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     }
   }
 
-  public ResWrap<Delta> delta(final InputStream input) throws XMLStreamException {
+  public ResWrap<Delta> delta(final InputStream input)
+      throws XMLStreamException, EdmPrimitiveTypeException {
     final XMLEventReader reader = getReader(input);
     final StartElement start = skipBeforeFirstStartElement(reader);
     return getContainer(start, delta(reader, start));
   }
 
-  private Delta delta(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+  private Delta delta(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
@@ -547,7 +559,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   private void properties(final XMLEventReader reader, final StartElement start, final EntityImpl entity)
-      throws XMLStreamException {
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
     final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
 
@@ -581,7 +593,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   private Annotation annotation(final XMLEventReader reader, final StartElement start)
-      throws XMLStreamException {
+      throws XMLStreamException, EdmPrimitiveTypeException {
 
     final Annotation annotation = new AnnotationImpl();
 
@@ -602,7 +614,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return entity;
   }
 
-  private Entity entity(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+  private Entity entity(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
     final EntityImpl entity;
     if (entryRefQName.equals(start.getName())) {
       entity = entityRef(start);
@@ -741,6 +754,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       }
     } catch (XMLStreamException e) {
       throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
     }
   }
 
@@ -761,7 +776,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     }
   }
 
-  private EntitySet entitySet(final XMLEventReader reader, final StartElement start) throws XMLStreamException {
+  private EntitySet entitySet(final XMLEventReader reader, final StartElement start)
+      throws XMLStreamException, EdmPrimitiveTypeException {
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
@@ -826,6 +842,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
       return getContainer(start, entitySet(reader, start));
     } catch (XMLStreamException e) {
       throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
     }
   }