You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/03/04 17:14:36 UTC

[1/3] olingo-odata4 git commit: [OLINGO-575] Start merging ComplexValue and LinkedComplexValue

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 033f35d61 -> 0d57a0763


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
index 0258edc..77d0ded 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Valuable;
@@ -51,7 +51,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.data.AnnotationImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
@@ -146,7 +146,7 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   protected String setInline(final String name, final String suffix, final JsonNode tree,
-          final ObjectCodec codec, final LinkImpl link) throws IOException {
+      final ObjectCodec codec, final LinkImpl link) throws IOException {
 
     final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
     if (tree.has(entityNamePrefix)) {
@@ -172,7 +172,7 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-          final JsonNode tree, final ObjectCodec codec) throws IOException {
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
     if (serverMode) {
       serverLinks(field, linked, toRemove, tree, codec);
     } else {
@@ -181,7 +181,7 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-          final JsonNode tree, final ObjectCodec codec) throws IOException {
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
 
     if (field.getKey().endsWith(jsonNavigationLink)) {
       final LinkImpl link = new LinkImpl();
@@ -210,10 +210,10 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
-          final JsonNode tree, final ObjectCodec codec) throws IOException {
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
 
     if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
-            || field.getKey().endsWith(jsonNavigationLink)) {
+        || field.getKey().endsWith(jsonNavigationLink)) {
 
       if (field.getValue().isValueNode()) {
         final String suffix = field.getKey().replaceAll("^.*@", "@");
@@ -272,19 +272,19 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
-    return node.isShort()      ? EdmPrimitiveTypeKind.Int16   :
-           node.isInt()        ? EdmPrimitiveTypeKind.Int32   :
-           node.isLong()       ? EdmPrimitiveTypeKind.Int64   :
-           node.isBoolean()    ? EdmPrimitiveTypeKind.Boolean :
-           node.isFloat()      ? EdmPrimitiveTypeKind.Single  :
-           node.isDouble()     ? EdmPrimitiveTypeKind.Double  :
-           node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
-                                 EdmPrimitiveTypeKind.String;
+    return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
+        node.isInt() ? EdmPrimitiveTypeKind.Int32 :
+            node.isLong() ? EdmPrimitiveTypeKind.Int64 :
+                node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
+                    node.isFloat() ? EdmPrimitiveTypeKind.Single :
+                        node.isDouble() ? EdmPrimitiveTypeKind.Double :
+                            node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
+                                EdmPrimitiveTypeKind.String;
   }
 
   protected void populate(final Annotatable annotatable, final List<Property> properties,
-          final ObjectNode tree, final ObjectCodec codec)
-          throws IOException, EdmPrimitiveTypeException {
+      final ObjectNode tree, final ObjectCodec codec)
+      throws IOException, EdmPrimitiveTypeException {
 
     String type = null;
     Annotation annotation = null;
@@ -310,8 +310,8 @@ public class JsonDeserializer implements ODataDeserializer {
         final PropertyImpl property = new PropertyImpl();
         property.setName(field.getKey());
         property.setType(type == null
-                ? null
-                : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
         type = null;
 
         value(property, field.getValue(), codec);
@@ -327,45 +327,39 @@ public class JsonDeserializer implements ODataDeserializer {
 
   private Object fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) throws EdmPrimitiveTypeException {
     return node.isNull() ? null
-            : typeInfo == null ? node.asText()
+        : typeInfo == null ? node.asText()
             : typeInfo.getPrimitiveTypeKind().isGeospatial()
-            ? getGeoDeserializer().deserialize(node, typeInfo)
-            : ((EdmPrimitiveType) typeInfo.getType())
-            .valueOfString(node.asText(), true, null,
-                    Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
-                    ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
+                ? getGeoDeserializer().deserialize(node, typeInfo)
+                : ((EdmPrimitiveType) typeInfo.getType())
+                    .valueOfString(node.asText(), true, null,
+                        Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
+                        ((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
   }
 
   private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
-          throws IOException, EdmPrimitiveTypeException {
+      throws IOException, EdmPrimitiveTypeException {
 
-    if (version.compareTo(ODataServiceVersion.V40) < 0) {
-      final List<Property> properties = new ArrayList<Property>();
-      populate(null, properties, node, codec);
-      return properties;
-    } else {
-      final LinkedComplexValue linkComplexValue = new LinkedComplexValueImpl();
-      final Set<String> toRemove = new HashSet<String>();
-      for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
-        final Map.Entry<String, JsonNode> field = itor.next();
-
-        links(field, linkComplexValue, toRemove, node, codec);
-      }
-      node.remove(toRemove);
+    final ComplexValue complexValue = new ComplexValueImpl();
+    final Set<String> toRemove = new HashSet<String>();
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
 
-      populate(linkComplexValue, linkComplexValue.getValue(), node, codec);
-      return linkComplexValue;
+      links(field, complexValue, toRemove, node, codec);
     }
+    node.remove(toRemove);
+
+    populate(complexValue, complexValue.getValue(), node, codec);
+    return complexValue;
   }
 
   private void fromCollection(final Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
-          final ObjectCodec codec) throws IOException, EdmPrimitiveTypeException {
+      final ObjectCodec codec) throws IOException, EdmPrimitiveTypeException {
 
     final 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();
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
 
     while (nodeItor.hasNext()) {
       final JsonNode child = nodeItor.next();
@@ -384,8 +378,7 @@ public class JsonDeserializer implements ODataDeserializer {
           ((ObjectNode) child).remove(jsonType);
         }
         final Object value = fromComplex((ObjectNode) child, codec);
-        valueType = value instanceof LinkedComplexValue ? ValueType.COLLECTION_LINKED_COMPLEX
-                : ValueType.COLLECTION_COMPLEX;
+        valueType = ValueType.COLLECTION_COMPLEX;
         values.add(value);
       }
     }
@@ -393,10 +386,10 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
-          throws IOException, EdmPrimitiveTypeException {
-    
+      throws IOException, EdmPrimitiveTypeException {
+
     EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType()) ? null
-            : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
+        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
 
     final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
     if (typeInfo == null) {
@@ -404,40 +397,40 @@ public class JsonDeserializer implements ODataDeserializer {
     }
 
     final ODataPropertyType propType = typeInfo == null ? guessed.getKey()
-            : typeInfo.isCollection() ? ODataPropertyType.COLLECTION
+        : typeInfo.isCollection() ? ODataPropertyType.COLLECTION
             : typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE
-            : node.isValueNode() ? ODataPropertyType.ENUM : ODataPropertyType.COMPLEX;
+                : node.isValueNode() ? ODataPropertyType.ENUM : ODataPropertyType.COMPLEX;
 
     switch (propType) {
-      case COLLECTION:
-        fromCollection(valuable, node.elements(), typeInfo, codec);
-        break;
-
-      case COMPLEX:
-        if (node.has(jsonType)) {
-          valuable.setType(node.get(jsonType).asText());
-          ((ObjectNode) node).remove(jsonType);
-        }
-        final Object value = fromComplex((ObjectNode) node, codec);
-        valuable.setValue(value instanceof LinkedComplexValue ? ValueType.LINKED_COMPLEX : ValueType.COMPLEX, value);
-        break;
+    case COLLECTION:
+      fromCollection(valuable, node.elements(), typeInfo, codec);
+      break;
+
+    case COMPLEX:
+      if (node.has(jsonType)) {
+        valuable.setType(node.get(jsonType).asText());
+        ((ObjectNode) node).remove(jsonType);
+      }
+      final Object value = fromComplex((ObjectNode) node, codec);
+      valuable.setValue(ValueType.COMPLEX, value);
+      break;
 
-      case ENUM:
-        valuable.setValue(ValueType.ENUM, node.asText());
-        break;
+    case ENUM:
+      valuable.setValue(ValueType.ENUM, node.asText());
+      break;
 
-      case PRIMITIVE:
-        if (valuable.getType() == null && typeInfo != null) {
-          valuable.setType(typeInfo.getFullQualifiedName().toString());
-        }
-        final Object primitiveValue = fromPrimitive(node, typeInfo);
-        valuable.setValue(primitiveValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE,
-                primitiveValue);
-        break;
-
-      case EMPTY:
-      default:
-        valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
+    case PRIMITIVE:
+      if (valuable.getType() == null && typeInfo != null) {
+        valuable.setType(typeInfo.getFullQualifiedName().toString());
+      }
+      final Object primitiveValue = fromPrimitive(node, typeInfo);
+      valuable.setValue(primitiveValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE,
+          primitiveValue);
+      break;
+
+    case EMPTY:
+    default:
+      valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
index 5b00a6a..14407a0 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertySerializer.java
@@ -80,12 +80,12 @@ public class JsonPropertySerializer extends JsonSerializer {
       jgen.writeStringField(Constants.VALUE, property.asEnum().toString());
     } else if (property.isGeospatial() || property.isCollection()) {
       valuable(jgen, property, Constants.VALUE);
-    } else if (property.isLinkedComplex()) {
-      for (Property cproperty : property.asLinkedComplex().getValue()) {
+    } else if (property.isComplex()) {
+      for (Property cproperty : property.asComplex().getValue()) {
         valuable(jgen, cproperty, cproperty.getName());
       }
     } else if (property.isComplex()) {
-      for (Property cproperty : property.asComplex()) {
+      for (Property cproperty : property.asComplex().getValue()) {
         valuable(jgen, cproperty, cproperty.getName());
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
index 3db0ea9..6a50ad3 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
@@ -30,7 +30,7 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Valuable;
@@ -280,13 +280,7 @@ public class JsonSerializer implements ODataSerializer {
           break;
 
         case COLLECTION_COMPLEX:
-          @SuppressWarnings("unchecked")
-          final List<Property> complexItem = (List<Property>) item;
-          complexValue(jgen, itemTypeInfo, complexItem, null);
-          break;
-
-        case COLLECTION_LINKED_COMPLEX:
-          final LinkedComplexValue complexItem2 = (LinkedComplexValue) item;
+          final ComplexValue complexItem2 = (ComplexValue) item;
           complexValue(jgen, itemTypeInfo, complexItem2.getValue(), complexItem2);
           break;
 
@@ -357,10 +351,8 @@ public class JsonSerializer implements ODataSerializer {
       jgen.writeEndObject();
     } else if (value.isCollection()) {
       collection(jgen, typeInfo, value.getValueType(), value.asCollection());
-    } else if (value.isLinkedComplex()) {
-      complexValue(jgen, typeInfo, value.asLinkedComplex().getValue(), value.asLinkedComplex());
     } else if (value.isComplex()) {
-      complexValue(jgen, typeInfo, value.asComplex(), null);
+      complexValue(jgen, typeInfo, value.asComplex().getValue(), value.asComplex());
     }
   }
 
@@ -368,7 +360,7 @@ public class JsonSerializer implements ODataSerializer {
           throws IOException, EdmPrimitiveTypeException {
 
     if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation)
-            && !valuable.isComplex() && !valuable.isLinkedComplex()) {
+            && !valuable.isComplex() && !valuable.isComplex()) {
 
       String type = valuable.getType();
       if (StringUtils.isBlank(type) && valuable.isPrimitive() || valuable.isNull()) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index c12fb27..bf03065 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
@@ -43,6 +44,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
@@ -357,7 +359,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   private Object readComplexNode(final EdmProperty edmProperty, final JsonNode jsonNode)
       throws DeserializerException {
     // read and add all complex properties
-    Object value = readComplexValue(edmProperty, jsonNode);
+    ComplexValue value = readComplexValue(edmProperty, jsonNode);
 
     final List<String> toRemove = new ArrayList<String>();
     Iterator<Entry<String, JsonNode>> fieldsIterator = jsonNode.fields();
@@ -430,7 +432,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private Object readComplexValue(EdmProperty edmComplexProperty, JsonNode jsonNode) throws DeserializerException {
+  private ComplexValue readComplexValue(EdmProperty edmComplexProperty, JsonNode jsonNode)
+      throws DeserializerException {
     if (isValidNull(edmComplexProperty, jsonNode)) {
       return null;
     }
@@ -440,7 +443,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
           DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, edmComplexProperty.getName());
     }
     // Even if there are no properties defined we have to give back an empty list
-    List<Property> propertyList = new ArrayList<Property>();
+    ComplexValueImpl complexValue = new ComplexValueImpl();
     EdmComplexType edmType = (EdmComplexType) edmComplexProperty.getType();
     // Check and consume all Properties
     for (String propertyName : edmType.getPropertyNames()) {
@@ -452,11 +455,11 @@ public class ODataJsonDeserializer implements ODataDeserializer {
               DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, propertyName);
         }
         Property property = consumePropertyNode(edmProperty, subNode);
-        propertyList.add(property);
+        complexValue.getValue().add(property);
         ((ObjectNode) jsonNode).remove(propertyName);
       }
     }
-    return propertyList;
+    return complexValue;
   }
 
   private boolean isNullable(EdmProperty edmProperty) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 6067312..e7a9cfb 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -25,12 +25,12 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
@@ -47,10 +47,10 @@ import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
 import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
+import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerException;
-import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
@@ -318,11 +318,9 @@ public class ODataJsonSerializer implements ODataSerializer {
         }
       } else if (edmProperty.isCollection()) {
         writeComplexCollection((EdmComplexType) edmProperty.getType(), property, selectedPaths, json);
-      } else if (property.isLinkedComplex()) {
-        writeComplexValue((EdmComplexType) edmProperty.getType(), property.asLinkedComplex().getValue(),
-            selectedPaths, json);
       } else if (property.isComplex()) {
-        writeComplexValue((EdmComplexType) edmProperty.getType(), property.asComplex(), selectedPaths, json);
+        writeComplexValue((EdmComplexType) edmProperty.getType(), property.asComplex().getValue(),
+            selectedPaths, json);
       } else {
         throw new SerializerException("Property type not yet supported!",
             SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
@@ -364,11 +362,8 @@ public class ODataJsonSerializer implements ODataSerializer {
     json.writeStartArray();
     for (Object value : property.asCollection()) {
       switch (property.getValueType()) {
-      case COLLECTION_LINKED_COMPLEX:
-        writeComplexValue(type, ((LinkedComplexValue) value).getValue(), selectedPaths, json);
-        break;
       case COLLECTION_COMPLEX:
-        writeComplexValue(type, ((Property) value).asComplex(), selectedPaths, json);
+        writeComplexValue(type, ((ComplexValue) value).getValue(), selectedPaths, json);
         break;
       default:
         throw new SerializerException("Property type not yet supported!",
@@ -487,11 +482,11 @@ public class ODataJsonSerializer implements ODataSerializer {
       if (contextURL != null) {
         json.writeStringField(Constants.JSON_CONTEXT, ContextURLBuilder.create(contextURL).toASCIIString());
       }
-      final List<Property> values = property.isNull() ? Collections.<Property> emptyList() :
-          property.isComplex() ? property.asComplex() : property.asLinkedComplex().getValue();
+      final List<Property> values =
+          property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue();
       writeProperties(type, values, options == null ? null : options.getSelect(), json);
-      if (!property.isNull() && property.isLinkedComplex()) {
-        writeNavigationProperties(type, property.asLinkedComplex(),
+      if (!property.isNull() && property.isComplex()) {
+        writeNavigationProperties(type, property.asComplex(),
             options == null ? null : options.getExpand(), json);
       }
       json.writeEndObject();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index da7cb08..742c5d5 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -28,10 +28,12 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
 import org.junit.Test;
@@ -39,9 +41,9 @@ import org.junit.Test;
 public class ODataJsonSerializerTest {
   @Test
   public void testCollectionComplex() throws ODataException, IOException {
-    final List<Property> col = new ArrayList<Property>();
-    col.add(new PropertyImpl(null, "ComplexOne", ValueType.COMPLEX, getValues(1)));
-    col.add(new PropertyImpl(null, "ComplexTwo", ValueType.COMPLEX, getValues(2)));
+    final List<ComplexValue> col = new ArrayList<ComplexValue>();
+    col.add(getValues(1));
+    col.add(getValues(2));
     final Property complexCollection = new PropertyImpl(null, "ComplexCol", ValueType.COLLECTION_COMPLEX, col);
     
     final ODataJsonSerializer serializer = new ODataJsonSerializer(ODataFormat.APPLICATION_JSON);
@@ -60,12 +62,10 @@ public class ODataJsonSerializerTest {
 
   }
 
-  private List<Property> getValues(int i) {
-    final List<Property> values = new ArrayList<Property>();
-
-    values.add(new PropertyImpl(null, "prop1", ValueType.PRIMITIVE, "test" + i));
-    values.add(new PropertyImpl(null, "prop2", ValueType.PRIMITIVE, "test" + i + i));
-
-    return values;
+  private ComplexValue getValues(int i) {
+    ComplexValue value = new ComplexValueImpl();
+    value.getValue().add(new PropertyImpl(null, "prop1", ValueType.PRIMITIVE, "test" + i));
+    value.getValue().add(new PropertyImpl(null, "prop2", ValueType.PRIMITIVE, "test" + i + i));
+    return value;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index e56093b..d2e7a91 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -32,13 +32,13 @@ import java.util.UUID;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 
 public class DataCreator {
@@ -97,10 +97,10 @@ public class DataCreator {
   
   private Entity createETKeyNavEntity(int propertyInt16, String propertyString) {
     // PropertyCompAllPrim
-    LinkedComplexValue cvCompAllPrim = createKeyNavAllPrimComplexValue();
+    ComplexValue cvCompAllPrim = createKeyNavAllPrimComplexValue();
     
     // CollPropertyComp
-    List<LinkedComplexValue> ccComp = new ArrayList<LinkedComplexValue>();
+    List<ComplexValue> ccComp = new ArrayList<ComplexValue>();
     ccComp.add(createCTPrimCompValue(1));
     ccComp.add(createCTPrimCompValue(2));
     ccComp.add(createCTPrimCompValue(3));
@@ -110,7 +110,7 @@ public class DataCreator {
       .addProperty(createPrimitive("PropertyString", propertyString))
       .addProperty(createComplex("PropertyComp", 
           createPrimitive("PropertyInt16", 1)))
-      .addProperty(new PropertyImpl(null, "PropertyCompAllPrim", ValueType.LINKED_COMPLEX,  cvCompAllPrim))
+      .addProperty(new PropertyImpl(null, "PropertyCompAllPrim", ValueType.COMPLEX,  cvCompAllPrim))
       .addProperty(createComplex("PropertyCompTwoPrim", 
           createPrimitive("PropertyInt16", 16), 
           createPrimitive("PropertyString", "Test123")))
@@ -119,18 +119,18 @@ public class DataCreator {
           "Employee2@company.example", 
           "Employee3@company.example"))
       .addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112))
-      .addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_LINKED_COMPLEX, ccComp))
+      .addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_COMPLEX, ccComp))
       .addProperty(createComplex("PropertyCompComp", 
           createPrimitive("PropertyString", "1"),
           createComplex("PropertyComp", createPrimitive("PropertyInt16", 1))));
   }
   
-  private LinkedComplexValue createCTPrimCompValue(int properyInt16) {
-    final LinkedComplexValue cvBasePrimCompNav = new LinkedComplexValueImpl();
-    final LinkedComplexValue cvAllPrim =  createKeyNavAllPrimComplexValue();
+  private ComplexValue createCTPrimCompValue(int properyInt16) {
+    final ComplexValue cvBasePrimCompNav = new ComplexValueImpl();
+    final ComplexValue cvAllPrim =  createKeyNavAllPrimComplexValue();
     
     cvBasePrimCompNav.getValue().add(createPrimitive("PropertyInt16", properyInt16));
-    cvBasePrimCompNav.getValue().add(new PropertyImpl(null, "PropertyComp", ValueType.LINKED_COMPLEX, cvAllPrim));
+    cvBasePrimCompNav.getValue().add(new PropertyImpl(null, "PropertyComp", ValueType.COMPLEX, cvAllPrim));
     
     return cvBasePrimCompNav;
   }
@@ -171,9 +171,9 @@ public class DataCreator {
               createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59))
           )
        ))
-      .addProperty(new PropertyImpl(null, "PropertyCompNav", ValueType.LINKED_COMPLEX, createCTPrimCompValue(1)))
-      .addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_LINKED_COMPLEX, 
-          new ArrayList<LinkedComplexValue>()))
+      .addProperty(new PropertyImpl(null, "PropertyCompNav", ValueType.COMPLEX, createCTPrimCompValue(1)))
+      .addProperty(new PropertyImpl(null, "CollPropertyComp", ValueType.COLLECTION_COMPLEX, 
+          new ArrayList<ComplexValue>()))
       .addProperty(createComplexCollection("CollPropertyCompNav", 
           Arrays.asList(createPrimitive("PropertyInt16", 1))))
       .addProperty(createPrimitiveCollection("CollPropertyString", 1, 2))
@@ -183,9 +183,9 @@ public class DataCreator {
       ));
   }
 
-  private LinkedComplexValue createKeyNavAllPrimComplexValue() {
-    LinkedComplexValue cvAllPrim;
-    cvAllPrim = new LinkedComplexValueImpl();
+  private ComplexValue createKeyNavAllPrimComplexValue() {
+    ComplexValue cvAllPrim;
+    cvAllPrim = new ComplexValueImpl();
     cvAllPrim.getValue().add(createPrimitive("PropertyString", "First Resource - positive values"));
     cvAllPrim.getValue().add(createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 } ));
     cvAllPrim.getValue().add(createPrimitive("PropertyBoolean", true));
@@ -677,21 +677,21 @@ public class DataCreator {
   }
 
   protected static Property createComplex(final String name, final Property... properties) {
-    LinkedComplexValue complexValue = new LinkedComplexValueImpl();
+    ComplexValue complexValue = new ComplexValueImpl();
     for (final Property property : properties) {
       complexValue.getValue().add(property);
     }
-    return new PropertyImpl(null, name, ValueType.LINKED_COMPLEX, complexValue);
+    return new PropertyImpl(null, name, ValueType.COMPLEX, complexValue);
   }
 
   protected static Property createComplexCollection(final String name, final List<Property>... propertiesList) {
-    List<LinkedComplexValue> complexCollection = new ArrayList<LinkedComplexValue>();
+    List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
     for (final List<Property> properties : propertiesList) {
-      LinkedComplexValue complexValue = new LinkedComplexValueImpl();
+      ComplexValue complexValue = new ComplexValueImpl();
       complexValue.getValue().addAll(properties);
       complexCollection.add(complexValue);
     }
-    return new PropertyImpl(null, name, ValueType.COLLECTION_LINKED_COMPLEX, complexCollection);
+    return new PropertyImpl(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
   }
 
   private Calendar getDateTime(final int year, final int month, final int day,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index b0bbd38..b28d263 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -244,7 +244,7 @@ public class DataProvider {
             newProperty = newProperty2;
           } else {
             newProperty = DataCreator.createComplex(propertyName);
-            createProperties((EdmComplexType) edmProperty.getType(), newProperty.asLinkedComplex().getValue());
+            createProperties((EdmComplexType) edmProperty.getType(), newProperty.asComplex().getValue());
           }
         }
         properties.add(newProperty);
@@ -282,7 +282,7 @@ public class DataProvider {
 
   private void applyNavigationBinding(final String rawBaseUri, final EdmEntitySet edmEntitySet,
       final Entity entity, final List<Link> navigationBindings) throws DataProviderException {
-    
+
     for (final Link link : navigationBindings) {
       final EdmNavigationProperty edmNavProperty = edmEntitySet.getEntityType().getNavigationProperty(link.getTitle());
       final EdmEntitySet edmTargetEntitySet =
@@ -308,11 +308,11 @@ public class DataProvider {
       final List<UriParameter> keys = odata.createUriHelper()
           .getKeyPredicatesFromEntityLink(edm, bindingLink, rawBaseUri);
       final Entity entity = read(edmEntitySetTarget, keys);
-      
-      if(entity == null) {
+
+      if (entity == null) {
         throw new DataProviderException("Entity " + bindingLink + " not found");
       }
-      
+
       return entity;
     } catch (DeserializerException e) {
       throw new DataProviderException("Invalid entity binding link", e);
@@ -383,7 +383,7 @@ public class DataProvider {
   // TODO Duplicated code in DataCreator
   private void setLink(final EdmNavigationProperty navigationProperty, final Entity srcEntity,
       final Entity destEntity) {
-    
+
     Link link = srcEntity.getNavigationLink(navigationProperty.getName());
     if (link == null) {
       link = new LinkImpl();
@@ -423,10 +423,12 @@ public class DataProvider {
     } else {
       final EdmComplexType type = (EdmComplexType) edmProperty.getType();
       for (final String propertyName : type.getPropertyNames()) {
-        final List<Property> newProperties = newProperty == null ? null :
-            newProperty.isComplex() ? newProperty.asComplex() : newProperty.asLinkedComplex().getValue();
+        List<Property> newProperties = null;
+        if(newProperty != null && newProperty.asComplex() != null){
+          newProperties = newProperty.asComplex().getValue();
+        }
         updateProperty(type.getStructuralProperty(propertyName),
-            findProperty(propertyName, property.asLinkedComplex().getValue()),
+            findProperty(propertyName, property.asComplex().getValue()),
             newProperties == null ? null : findProperty(propertyName, newProperties),
             patch);
       }
@@ -459,7 +461,7 @@ public class DataProvider {
   public void setOData(final OData odata) {
     this.odata = odata;
   }
-  
+
   public static class DataProviderException extends ODataApplicationException {
     private static final long serialVersionUID = 5098059649321796156L;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 596fe95..bf1ffb5 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -259,7 +259,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
   private void deleteProperty(final ODataResponse response, final UriInfo uriInfo) throws ODataApplicationException {
     final UriInfoResource resource = uriInfo.asUriInfoResource();
     validatePath(resource);
-    getEdmEntitySet(uriInfo);  // including checks
+    getEdmEntitySet(uriInfo); // including checks
 
     final List<UriResource> resourceParts = resource.getUriResourceParts();
     final List<String> path = getPropertyPath(resourceParts, 0);
@@ -281,9 +281,8 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
       throws ODataApplicationException {
     Property property = entity.getProperty(path.get(0));
     for (final String name : path.subList(1, path.size())) {
-      if (property != null && (property.isLinkedComplex() || property.isComplex())) {
-        final List<Property> complex = property.isLinkedComplex() ?
-            property.asLinkedComplex().getValue() : property.asComplex();
+      if (property != null && (property.isComplex() || property.isComplex())) {
+        final List<Property> complex = property.asComplex().getValue();
         property = null;
         for (final Property innerProperty : complex) {
           if (innerProperty.getName().equals(name)) {
@@ -320,7 +319,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
     final UriInfoResource resource = uriInfo.asUriInfoResource();
     validateOptions(resource);
     validatePath(resource);
-    getEdmEntitySet(uriInfo);  // including checks
+    getEdmEntitySet(uriInfo); // including checks
 
     final List<UriResource> resourceParts = resource.getUriResourceParts();
     final List<String> path = getPropertyPath(resourceParts, 1);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index bebe1f8..b72cfec 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -189,9 +189,8 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
     for (int i = 1; i < uriResourceParts.size(); i++) {
       currentType = ((UriResourcePartTyped) uriResourceParts.get(i)).getType();
 
-      if (currentProperty.isComplex() || currentProperty.isLinkedComplex()) {
-        final List<Property> complex = currentProperty.isLinkedComplex() ?
-            currentProperty.asLinkedComplex().getValue() : currentProperty.asComplex();
+      if (currentProperty.isComplex()) {
+        final List<Property> complex = currentProperty.asComplex().getValue();
 
         for (final Property innerProperty : complex) {
           if (innerProperty.getName().equals(uriResourceParts.get(i).toString())) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index 63d8550..76edb33 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -24,7 +24,7 @@ import java.util.List;
 
 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.ComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -125,8 +125,8 @@ public class DataProviderTest {
     Assert.assertEquals(3, outSet.getEntities().size());
     Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
     Property complex = outSet.getEntities().get(0).getProperties().get(1);
-    Assert.assertTrue(complex.isLinkedComplex());
-    Assert.assertEquals(16, complex.asLinkedComplex().getValue().size());
+    Assert.assertTrue(complex.isComplex());
+    Assert.assertEquals(16, complex.asComplex().getValue().size());
     Assert.assertEquals(2, outSet.getEntities().get(1).getProperties().size());
     Assert.assertEquals(2, outSet.getEntities().get(2).getProperties().size());
   }
@@ -138,13 +138,13 @@ public class DataProviderTest {
     Assert.assertEquals(3, outSet.getEntities().size());
     Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size());
     Property complex = outSet.getEntities().get(0).getProperties().get(2);
-    Assert.assertTrue(complex.isLinkedComplex());
-    Assert.assertEquals(2, complex.asLinkedComplex().getValue().size());
+    Assert.assertTrue(complex.isComplex());
+    Assert.assertEquals(2, complex.asComplex().getValue().size());
     Property complexCollection = outSet.getEntities().get(0).getProperties().get(3);
     Assert.assertTrue(complexCollection.isCollection());
     List<?> linkedComplexValues = complexCollection.asCollection();
     Assert.assertEquals(3, linkedComplexValues.size());
-    LinkedComplexValue linkedComplexValue = (LinkedComplexValue) linkedComplexValues.get(0);
+    ComplexValue linkedComplexValue = (ComplexValue) linkedComplexValues.get(0);
     Assert.assertEquals(2, linkedComplexValue.getValue().size());
     Property lcProp = linkedComplexValue.getValue().get(0);
     Assert.assertFalse(lcProp.isCollection());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index ff54e1e..54a998c 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -35,6 +35,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
@@ -231,7 +232,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     assertNotNull(entity.getProperty("PropertyComp"));
     assertNotNull(entity.getProperty("PropertyComp") instanceof List);
-    List<Property> complexProperties = entity.getProperty("PropertyComp").asComplex();
+    List<Property> complexProperties = entity.getProperty("PropertyComp").asComplex().getValue();
     assertEquals(16, complexProperties.size());
   }
 
@@ -284,7 +285,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals(true, asCollection.get(2));
   }
 
-  @SuppressWarnings("unchecked")
   @Test
   public void simpleEntityETMixPrimCollComp() throws Exception {
     final String entityString = "{"
@@ -314,13 +314,12 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals(3, asCollection.size());
 
     for (Object arrayElement : asCollection) {
-      assertTrue(arrayElement instanceof List);
-      List<Object> castedArrayElement = (List<Object>) arrayElement;
+      assertTrue(arrayElement instanceof ComplexValue);
+      List<Property> castedArrayElement = (List<Property>) ((ComplexValue) arrayElement).getValue();
       assertEquals(2, castedArrayElement.size());
     }
   }
 
-  @SuppressWarnings("unchecked")
   @Test
   public void eTMixPrimCollCompMIssingPropertyInComplexType() throws Exception {
     final String entityString = "{"
@@ -341,7 +340,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     Property complexProperty = entity.getProperty("PropertyComp");
     assertEquals(ValueType.COMPLEX, complexProperty.getValueType());
-    List<Property> complexPropertyValues = (List<Property>) complexProperty.getValue();
+    List<Property> complexPropertyValues = (List<Property>) complexProperty.asComplex().getValue();
     assertEquals(1, complexPropertyValues.size());
 
     Property property = entity.getProperty("CollPropertyComp");
@@ -352,8 +351,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals(3, asCollection.size());
 
     for (Object arrayElement : asCollection) {
-      assertTrue(arrayElement instanceof List);
-      List<Object> castedArrayElement = (List<Object>) arrayElement;
+      assertTrue(arrayElement instanceof ComplexValue);
+      List<Property> castedArrayElement = (List<Property>) ((ComplexValue) arrayElement).getValue();
       assertEquals(1, castedArrayElement.size());
     }
   }
@@ -495,7 +494,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertTrue(bindingToMany.getBindingLinks().isEmpty());
   }
 
-  @SuppressWarnings("unchecked")
   @Test
   public void eTMixEnumDefCollCompTest() throws Exception {
     InputStream stream = getFileAsStream("EntityETMixEnumDefCollComp.json");
@@ -515,7 +513,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals("string", defProperty.getValue());
 
     Property complexProperty = entity.getProperty("PropertyCompMixedEnumDef");
-    List<Property> value = (List<Property>) complexProperty.getValue();
+    List<Property> value = (List<Property>) complexProperty.asComplex().getValue();
     assertEquals((short) 2, value.get(0).getValue());
   }
 
@@ -566,7 +564,6 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertNull(entity.getProperty("PropertyComp").getValue());
   }
 
-  @SuppressWarnings("unchecked")
   @Test
   public void validJsonValueForComplexCollectionNullValue() throws Exception {
     final String entityString = "{"
@@ -580,7 +577,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
     List<?> collPropertyComp = entity.getProperty("CollPropertyComp").asCollection();
     assertNull(collPropertyComp.get(0));
-    List<Property> complexPropertyProperties = (List<Property>) collPropertyComp.get(1);
+    List<Property> complexPropertyProperties = (List<Property>) ((ComplexValue) collPropertyComp.get(1)).getValue();
     assertEquals(Short.valueOf((short) 789), complexPropertyProperties.get(0).getValue());
     assertEquals("TEST 3", complexPropertyProperties.get(1).getValue());
   }
@@ -595,8 +592,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     Entity entity = deserializer.entity(stream, edm.getEntityType(
         new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim")));
 
-    assertEquals("TEST A", entity.getProperty("PropertyComp").asComplex().get(0).getValue());
-    assertNull(entity.getProperty("PropertyComp").asComplex().get(1).getValue());
+    assertEquals("TEST A", entity.getProperty("PropertyComp").asComplex().getValue().get(0).getValue());
+    assertNull(entity.getProperty("PropertyComp").asComplex().getValue().get(1).getValue());
   }
 
   @Test
@@ -614,7 +611,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     assertEquals((short) 2, e.getProperty("PropertyEnumString").getValue());
     Property propertyCompMixedEnumDef = e.getProperty("PropertyCompMixedEnumDef");
-    assertNull(propertyCompMixedEnumDef.asComplex().get(0).getValue());
+    assertNull(propertyCompMixedEnumDef.asComplex().getValue().get(0).getValue());
   }
 
   @Test


[3/3] olingo-odata4 git commit: [OLINGO-575] Start merging ComplexValue and LinkedComplexValue

Posted by ch...@apache.org.
[OLINGO-575] Start merging ComplexValue and LinkedComplexValue


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/0d57a076
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/0d57a076
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/0d57a076

Branch: refs/heads/master
Commit: 0d57a0763a70e1875f15b8882b9008f88772cfac
Parents: 033f35d
Author: Christian Amend <ch...@apache.org>
Authored: Wed Mar 4 17:13:55 2015 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Wed Mar 4 17:13:55 2015 +0100

----------------------------------------------------------------------
 .../commons/AnnotatableInvocationHandler.java   |  25 +-
 .../proxy/commons/ComplexInvocationHandler.java |  34 +-
 .../olingo/ext/proxy/utils/CoreUtils.java       |   2 +-
 .../org/apache/olingo/fit/AbstractServices.java | 787 ++++++++++---------
 .../java/org/apache/olingo/fit/V4Services.java  |   8 +-
 .../olingo/fit/tecsvc/client/BasicITCase.java   |  14 +-
 .../fit/v4/BoundOperationInvokeTestITCase.java  |   8 +-
 .../olingo/fit/v4/DerivedTypeTestITCase.java    |  15 +-
 .../olingo/fit/v4/OpenTypeTestITCase.java       |  19 +-
 .../fit/v4/OperationImportInvokeTestITCase.java |  32 +-
 .../core/serialization/ODataBinderImpl.java     | 101 +--
 .../olingo/client/core/v4/EntityTest.java       |   6 +-
 .../apache/olingo/client/core/v4/JSONTest.java  |  15 +-
 .../olingo/client/core/v4/PropertyTest.java     |   2 +-
 .../olingo/commons/api/data/ComplexValue.java   |  26 +
 .../commons/api/data/LinkedComplexValue.java    |  26 -
 .../olingo/commons/api/data/Valuable.java       |   6 +-
 .../olingo/commons/api/data/ValueType.java      |   5 +-
 .../commons/api/domain/AbstractODataValue.java  |   5 +-
 .../commons/api/domain/ODataComplexValue.java   |   6 +-
 .../api/domain/ODataLinkedComplexValue.java     |  25 -
 .../commons/api/domain/ODataObjectFactory.java  |   6 +-
 .../commons/api/domain/ODataValuable.java       |   9 +-
 .../olingo/commons/api/domain/ODataValue.java   |  19 +-
 .../commons/core/data/AbstractValuable.java     |  24 +-
 .../commons/core/data/ComplexValueImpl.java     |  88 +++
 .../core/data/LinkedComplexValueImpl.java       |  88 ---
 .../core/domain/ODataAnnotationImpl.java        |   9 +-
 .../core/domain/ODataCollectionValueImpl.java   |  18 +-
 .../core/domain/ODataComplexValueImpl.java      |  30 +-
 .../commons/core/domain/ODataEnumValueImpl.java |   8 +-
 .../core/domain/ODataObjectFactoryImpl.java     |  21 +-
 .../core/domain/ODataPrimitiveValueImpl.java    |  12 +-
 .../commons/core/domain/ODataPropertyImpl.java  |  18 +-
 .../commons/core/domain/ODataValuableImpl.java  |  13 +-
 .../core/serialization/AtomDeserializer.java    |  21 +-
 .../core/serialization/AtomSerializer.java      |  47 +-
 .../core/serialization/JsonDeserializer.java    | 147 ++--
 .../serialization/JsonPropertySerializer.java   |   6 +-
 .../core/serialization/JsonSerializer.java      |  16 +-
 .../json/ODataJsonDeserializer.java             |  13 +-
 .../serializer/json/ODataJsonSerializer.java    |  23 +-
 .../json/ODataJsonSerializerTest.java           |  20 +-
 .../olingo/server/tecsvc/data/DataCreator.java  |  42 +-
 .../olingo/server/tecsvc/data/DataProvider.java |  22 +-
 .../TechnicalPrimitiveComplexProcessor.java     |   9 +-
 .../expression/ExpressionVisitorImpl.java       |   5 +-
 .../server/tecsvc/data/DataProviderTest.java    |  12 +-
 .../json/ODataJsonDeserializerEntityTest.java   |  27 +-
 49 files changed, 873 insertions(+), 1067 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
index b08afba..16ef932 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
@@ -18,16 +18,6 @@
  */
 package org.apache.olingo.ext.proxy.commons;
 
-import org.apache.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
-import org.apache.olingo.ext.proxy.api.AbstractTerm;
-import org.apache.olingo.ext.proxy.api.Annotatable;
-import org.apache.olingo.ext.proxy.api.annotations.Namespace;
-import org.apache.olingo.ext.proxy.api.annotations.Term;
-import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
-import org.apache.olingo.ext.proxy.utils.CoreUtils;
-
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
@@ -37,7 +27,16 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.olingo.commons.api.domain.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.AbstractTerm;
+import org.apache.olingo.ext.proxy.api.Annotatable;
+import org.apache.olingo.ext.proxy.api.annotations.Namespace;
+import org.apache.olingo.ext.proxy.api.annotations.Term;
+import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
 
 public class AnnotatableInvocationHandler extends AbstractInvocationHandler implements Annotatable {
 
@@ -87,11 +86,11 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
                 ? ((org.apache.olingo.commons.api.domain.ODataLink) ((ODataEntity) targetHandler.getInternal()).
                 getNavigationLink(navPropName)).getAnnotations()
                 : ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
-      } else if (targetHandler.getInternal() instanceof ODataLinkedComplexValue) {
+      } else if (targetHandler.getInternal() instanceof ODataComplexValue) {
         result = propName == null
-                ? ((org.apache.olingo.commons.api.domain.ODataLink) ((ODataLinkedComplexValue) targetHandler.
+                ? ((org.apache.olingo.commons.api.domain.ODataLink) ((ODataComplexValue) targetHandler.
                 getInternal()).getNavigationLink(navPropName)).getAnnotations()
-                : ((ODataLinkedComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
+                : ((ODataComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
index 29b0708..2e1deb6 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
@@ -39,7 +39,7 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
 public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
 
-  private static Pair<ODataComplexValue<? extends ODataProperty>, Class<?>> init(
+  private static Pair<ODataComplexValue, Class<?>> init(
           final Class<?> typeRef,
           final AbstractService<?> service) {
 
@@ -57,10 +57,10 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
 
     final FullQualifiedName typeName =
             new FullQualifiedName(ClassUtils.getNamespace(complexTypeRef), annotation.name());
-    final ODataComplexValue<? extends ODataProperty> complex =
+    final ODataComplexValue complex =
             service.getClient().getObjectFactory().newComplexValue(typeName.toString());
 
-    return new ImmutablePair<ODataComplexValue<? extends ODataProperty>, Class<?>>(complex, complexTypeRef);
+    return new ImmutablePair<ODataComplexValue, Class<?>>(complex, complexTypeRef);
   }
 
   public static ComplexInvocationHandler getInstance(
@@ -68,12 +68,12 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
           final EntityInvocationHandler handler,
           final Class<?> typeRef) {
 
-    final Pair<ODataComplexValue<? extends ODataProperty>, Class<?>> init = init(typeRef, handler.service);
+    final Pair<ODataComplexValue, Class<?>> init = init(typeRef, handler.service);
     return new ComplexInvocationHandler(init.getLeft(), init.getRight(), handler);
   }
 
   public static ComplexInvocationHandler getInstance(
-          final ODataComplexValue<?> complex,
+          final ODataComplexValue complex,
           final Class<?> typeRef,
           final AbstractService<?> service) {
 
@@ -84,7 +84,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
           final Class<?> typeRef,
           final AbstractService<?> service) {
       
-    final Pair<ODataComplexValue<? extends ODataProperty>, Class<?>> init = init(typeRef, service);
+    final Pair<ODataComplexValue, Class<?>> init = init(typeRef, service);
     return new ComplexInvocationHandler(init.getLeft(), init.getRight(), service);
   }
 
@@ -93,12 +93,12 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
           final AbstractService<?> service,
           final URIBuilder uri) {
       
-    final Pair<ODataComplexValue<? extends ODataProperty>, Class<?>> init = init(typeRef, service);
+    final Pair<ODataComplexValue, Class<?>> init = init(typeRef, service);
     return new ComplexInvocationHandler(init.getLeft(), init.getRight(), service, uri);
   }
 
   public static ComplexInvocationHandler getInstance(
-          final ODataComplexValue<? extends ODataProperty> complex,
+          final ODataComplexValue complex,
           final Class<?> typeRef,
           final AbstractService<?> service,
           final URIBuilder uri) {
@@ -107,7 +107,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
   }
 
   private ComplexInvocationHandler(
-          final ODataComplexValue<? extends ODataProperty> complex,
+          final ODataComplexValue complex,
           final Class<?> typeRef,
           final AbstractService<?> service,
           final URIBuilder uri) {
@@ -118,7 +118,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
   }
 
   private ComplexInvocationHandler(
-          final ODataComplexValue<? extends ODataProperty> complex,
+          final ODataComplexValue complex,
           final Class<?> typeRef,
           final EntityInvocationHandler handler) {
 
@@ -127,7 +127,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
   }
 
   private ComplexInvocationHandler(
-          final ODataComplexValue<? extends ODataProperty> complex,
+          final ODataComplexValue complex,
           final Class<?> typeRef,
           final AbstractService<?> service) {
 
@@ -135,9 +135,8 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
     this.uri = null;
   }
 
-  @SuppressWarnings("unchecked")
-  public ODataComplexValue<ODataProperty> getComplex() {
-    return (ODataComplexValue<ODataProperty>) this.internal;
+  public ODataComplexValue getComplex() {
+    return (ODataComplexValue) this.internal;
   }
 
   @Override
@@ -174,12 +173,11 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
   }
 
   @Override
-  @SuppressWarnings("unchecked")
-  protected <T extends ODataProperty> List<T> getInternalProperties() {
-    final List<T> res = new ArrayList<T>();
+  protected List<ODataProperty> getInternalProperties() {
+    final List<ODataProperty> res = new ArrayList<ODataProperty>();
     if (getComplex() != null) {
       for (ODataProperty property : getComplex()) {
-        res.add((T) property);
+        res.add(property);
       }
     }
     return res;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
index 7ab03a6..6e3f68c 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
@@ -308,7 +308,7 @@ public final class CoreUtils {
   public static void addProperties(
       final EdmEnabledODataClient client,
       final Map<String, Object> changes,
-      final ODataComplexValue<ODataProperty> entity) {
+      final ODataComplexValue entity) {
 
     for (Map.Entry<String, Object> entry : changes.entrySet()) {
       entity.add(getODataComplexProperty(

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index 3d70109..77e3478 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -18,8 +18,49 @@
  */
 package org.apache.olingo.fit;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.mail.Header;
+import javax.mail.internet.MimeBodyPart;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -27,13 +68,12 @@ import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
-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.ValueType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -67,47 +107,8 @@ import org.apache.olingo.fit.utils.XMLUtilities;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.mail.Header;
-import javax.mail.internet.MimeBodyPart;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.net.URI;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.ConcurrentModificationException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 
 public abstract class AbstractServices {
 
@@ -173,9 +174,9 @@ public abstract class AbstractServices {
       }
 
       return xml.createResponse(
-              null,
-              FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType),
-              null, acceptType);
+          null,
+          FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType),
+          null, acceptType);
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
     }
@@ -206,13 +207,13 @@ public abstract class AbstractServices {
   @Consumes(MULTIPART_MIXED)
   @Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
   public Response batch(
-          @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          final @Multipart MultipartBody attachment) {
+      @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      final @Multipart MultipartBody attachment) {
     try {
       final boolean continueOnError = prefer.contains("odata.continue-on-error");
       return xml.createBatchResponse(
-              exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
+          exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
     } catch (IOException e) {
       return xml.createFaultResponse(Accept.XML.toString(version), e);
     }
@@ -260,10 +261,11 @@ public abstract class AbstractServices {
     // just for non nullable property test into PropertyTestITCase
     return xml.createFaultResponse(Accept.JSON_FULLMETA.toString(version), new Exception("Non nullable properties"));
   }
+
   // ----------------------------------------------
 
   protected Response bodyPartRequest(final MimeBodyPart body) throws Exception {
-    return bodyPartRequest(body, Collections.<String, String>emptyMap());
+    return bodyPartRequest(body, Collections.<String, String> emptyMap());
   }
 
   protected Response bodyPartRequest(final MimeBodyPart body, final Map<String, String> references) throws Exception {
@@ -272,7 +274,7 @@ public abstract class AbstractServices {
 
     Header header = en.nextElement();
     final String request =
-            header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");
+        header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");
 
     final Matcher matcher = REQUEST_PATTERN.matcher(request);
     final Matcher matcherRef = BATCH_REQUEST_REF_PATTERN.matcher(request);
@@ -327,15 +329,15 @@ public abstract class AbstractServices {
       }
 
       // When updating to CXF 3.0.1, uncomment the following line, see CXF-5865
-      //client.close();
+      // client.close();
     }
 
     return res;
   }
 
   protected abstract InputStream exploreMultipart(
-          final List<Attachment> attachments, final String boundary, final boolean continueOnError)
-          throws IOException;
+      final List<Attachment> attachments, final String boundary, final boolean continueOnError)
+      throws IOException;
 
   protected void addItemIntro(final ByteArrayOutputStream bos) throws IOException {
     addItemIntro(bos, null);
@@ -356,7 +358,7 @@ public abstract class AbstractServices {
   }
 
   protected void addChangesetItemIntro(
-          final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException {
+      final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException {
     bos.write(("--" + cboundary).getBytes());
     bos.write(Constants.CRLF);
     bos.write(("Content-ID: " + contentId).getBytes());
@@ -365,12 +367,12 @@ public abstract class AbstractServices {
   }
 
   protected void addSingleBatchResponse(
-          final Response response, final ByteArrayOutputStream bos) throws IOException {
+      final Response response, final ByteArrayOutputStream bos) throws IOException {
     addSingleBatchResponse(response, null, bos);
   }
 
   protected void addSingleBatchResponse(
-          final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException {
+      final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException {
     bos.write("HTTP/1.1 ".getBytes());
     bos.write(String.valueOf(response.getStatusInfo().getStatusCode()).getBytes());
     bos.write(" ".getBytes());
@@ -407,45 +409,45 @@ public abstract class AbstractServices {
   }
 
   protected void addErrorBatchResponse(final Exception e, final ByteArrayOutputStream bos)
-          throws IOException {
+      throws IOException {
     addErrorBatchResponse(e, null, bos);
   }
 
   protected void addErrorBatchResponse(final Exception e, final String contentId, final ByteArrayOutputStream bos)
-          throws IOException {
+      throws IOException {
     addSingleBatchResponse(xml.createFaultResponse(Accept.XML.toString(version), e), contentId, bos);
   }
 
   @MERGE
   @Path("/{entitySetName}({entityId})")
-  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
   public Response mergeEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      final String changes) {
 
     return patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
   }
 
   @PATCH
   @Path("/{entitySetName}({entityId})")
-  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
   public Response patchEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      final String changes) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -469,7 +471,7 @@ public abstract class AbstractServices {
         throw new UnsupportedMediaTypeException("Unsupported media type");
       } else if (contentTypeValue == Accept.ATOM) {
         entryChanges = atomDeserializer.toEntity(
-                IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload();
+            IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload();
       } else {
         final ResWrap<Entity> jcont = jsonDeserializer.toEntity(IOUtils.toInputStream(changes, Constants.ENCODING));
         entryChanges = jcont.getPayload();
@@ -497,7 +499,7 @@ public abstract class AbstractServices {
       writer.close();
 
       final InputStream res = xml.addOrReplaceEntity(
-              entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
+          entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
 
       final ResWrap<Entity> cres = atomDeserializer.toEntity(res);
 
@@ -505,25 +507,25 @@ public abstract class AbstractServices {
 
       final String path = Commons.getEntityBasePath(entitySetName, entityId);
       FSManager.instance(version).putInMemory(
-              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
+          cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
         response = xml.createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                xml.readEntity(entitySetName, entityId, acceptType).getValue(),
-                null, acceptType, Response.Status.OK);
+            uriInfo.getRequestUri().toASCIIString(),
+            xml.readEntity(entitySetName, entityId, acceptType).getValue(),
+            null, acceptType, Response.Status.OK);
       } else {
         res.close();
         response = xml.createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                null,
-                null,
-                acceptType, Response.Status.NO_CONTENT);
+            uriInfo.getRequestUri().toASCIIString(),
+            null,
+            null,
+            acceptType, Response.Status.NO_CONTENT);
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -534,16 +536,16 @@ public abstract class AbstractServices {
 
   @PUT
   @Path("/{entitySetName}({entityId})")
-  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
   public Response replaceEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          final String entity) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      final String entity) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -553,8 +555,8 @@ public abstract class AbstractServices {
       }
 
       final InputStream res = getUtilities(acceptType).addOrReplaceEntity(entityId, entitySetName,
-              IOUtils.toInputStream(entity, Constants.ENCODING),
-              xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
+          IOUtils.toInputStream(entity, Constants.ENCODING),
+          xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
 
       final ResWrap<Entity> cres;
       if (acceptType == Accept.ATOM) {
@@ -565,28 +567,28 @@ public abstract class AbstractServices {
 
       final String path = Commons.getEntityBasePath(entitySetName, entityId);
       FSManager.instance(version).putInMemory(
-              cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
+          cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
         response = xml.createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                xml.readEntity(entitySetName, entityId, acceptType).getValue(),
-                null,
-                acceptType,
-                Response.Status.OK);
+            uriInfo.getRequestUri().toASCIIString(),
+            xml.readEntity(entitySetName, entityId, acceptType).getValue(),
+            null,
+            acceptType,
+            Response.Status.OK);
       } else {
         res.close();
         response = xml.createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                null,
-                null,
-                acceptType,
-                Response.Status.NO_CONTENT);
+            uriInfo.getRequestUri().toASCIIString(),
+            null,
+            null,
+            acceptType,
+            Response.Status.NO_CONTENT);
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -597,15 +599,15 @@ public abstract class AbstractServices {
 
   @POST
   @Path("/{entitySetName}")
-  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM})
+  @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM })
   public Response postNewEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          final String entity) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      final String entity) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -634,11 +636,11 @@ public abstract class AbstractServices {
           prop.setName(id.getKey());
           prop.setType(id.getValue().toString());
           prop.setValue(ValueType.PRIMITIVE,
-                  id.getValue() == EdmPrimitiveTypeKind.Int32
+              id.getValue() == EdmPrimitiveTypeKind.Int32
                   ? Integer.parseInt(entityKey)
                   : id.getValue() == EdmPrimitiveTypeKind.Guid
-                  ? UUID.fromString(entityKey)
-                  : entityKey);
+                      ? UUID.fromString(entityKey)
+                      : entityKey);
           entry.getProperties().add(prop);
         }
 
@@ -673,13 +675,13 @@ public abstract class AbstractServices {
       writer.close();
 
       final InputStream serialization =
-              xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
+          xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
 
       ResWrap<Entity> result = atomDeserializer.toEntity(serialization);
       result = new ResWrap<Entity>(
-              URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+          URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
               + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
-              null, result.getPayload());
+          null, result.getPayload());
 
       final String path = Commons.getEntityBasePath(entitySetName, entityKey);
       FSManager.instance(version).putInMemory(result, path + Constants.get(version, ConstantKey.ENTITY));
@@ -702,22 +704,22 @@ public abstract class AbstractServices {
       final Response response;
       if ("return-no-content".equalsIgnoreCase(prefer)) {
         response = xml.createResponse(
-                location,
-                null,
-                null,
-                acceptType,
-                Response.Status.NO_CONTENT);
+            location,
+            null,
+            null,
+            acceptType,
+            Response.Status.NO_CONTENT);
       } else {
         response = xml.createResponse(
-                location,
-                xml.writeEntity(acceptType, result),
-                null,
-                acceptType,
-                Response.Status.CREATED);
+            location,
+            xml.writeEntity(acceptType, result),
+            null,
+            acceptType,
+            Response.Status.CREATED);
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -730,10 +732,10 @@ public abstract class AbstractServices {
   @POST
   @Path("/Person({entityId})/{type:.*}/Sack")
   public Response actionSack(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @PathParam("type") final String type,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @PathParam("type") final String type,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
@@ -752,7 +754,7 @@ public abstract class AbstractServices {
 
       final FSManager fsManager = FSManager.instance(version);
       fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
-              fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version,
+          fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version,
               ConstantKey.ENTITY), Accept.ATOM));
 
       return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
@@ -764,10 +766,10 @@ public abstract class AbstractServices {
   @POST
   @Path("/Person/{type:.*}/IncreaseSalaries")
   public Response actionIncreaseSalaries(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("type") final String type,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String body) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("type") final String type,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String body) {
 
     final String name = "Person";
     try {
@@ -783,12 +785,12 @@ public abstract class AbstractServices {
       final int n = tree.get("n").asInt();
 
       final StringBuilder path = new StringBuilder(name).
-              append(File.separatorChar).append(type).
-              append(File.separatorChar);
+          append(File.separatorChar).append(type).
+          append(File.separatorChar);
 
       path.append(metadata.getEntitySet(name).isSingleton()
-              ? Constants.get(version, ConstantKey.ENTITY)
-              : Constants.get(version, ConstantKey.FEED));
+          ? Constants.get(version, ConstantKey.ENTITY)
+          : Constants.get(version, ConstantKey.FEED));
 
       final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
 
@@ -798,20 +800,20 @@ public abstract class AbstractServices {
 
       String newContent = new String(copy.toByteArray(), "UTF-8");
       final Pattern salary = Pattern.compile(acceptType == Accept.ATOM
-              ? "\\<d:Salary m:type=\"Edm.Int32\"\\>(-?\\d+)\\</d:Salary\\>"
-              : "\"Salary\":(-?\\d+),");
+          ? "\\<d:Salary m:type=\"Edm.Int32\"\\>(-?\\d+)\\</d:Salary\\>"
+          : "\"Salary\":(-?\\d+),");
       final Matcher salaryMatcher = salary.matcher(newContent);
       while (salaryMatcher.find()) {
         final Long newSalary = Long.valueOf(salaryMatcher.group(1)) + n;
         newContent = newContent.
-                replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",",
+            replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",",
                 "\"Salary\":" + newSalary + ",").
-                replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>" + salaryMatcher.group(1) + "</d:Salary\\>",
+            replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>" + salaryMatcher.group(1) + "</d:Salary\\>",
                 "<d:Salary m:type=\"Edm.Int32\">" + newSalary + "</d:Salary>");
       }
 
       FSManager.instance(version).putInMemory(IOUtils.toInputStream(newContent, Constants.ENCODING),
-              FSManager.instance(version).getAbsolutePath(path.toString(), acceptType));
+          FSManager.instance(version).getAbsolutePath(path.toString(), acceptType));
 
       return xml.createResponse(null, null, null, acceptType, Response.Status.NO_CONTENT);
     } catch (Exception e) {
@@ -822,10 +824,10 @@ public abstract class AbstractServices {
   @POST
   @Path("/Product({entityId})/ChangeProductDimensions")
   public Response actionChangeProductDimensions(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String argument) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String argument) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
@@ -846,7 +848,7 @@ public abstract class AbstractServices {
 
       final FSManager fsManager = FSManager.instance(version);
       fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
-              fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version,
+          fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version,
               ConstantKey.ENTITY), Accept.ATOM));
 
       return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
@@ -858,10 +860,10 @@ public abstract class AbstractServices {
   @POST
   @Path("/ComputerDetail({entityId})/ResetComputerDetailsSpecifications")
   public Response actionResetComputerDetailsSpecifications(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String argument) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String argument) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
@@ -884,7 +886,7 @@ public abstract class AbstractServices {
 
       final FSManager fsManager = FSManager.instance(version);
       fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
-              fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version,
+          fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version,
               ConstantKey.ENTITY), Accept.ATOM));
 
       return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
@@ -904,9 +906,9 @@ public abstract class AbstractServices {
   @GET
   @Path("/{name}/{type:[a-zA-Z].*}")
   public Response getEntitySet(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("name") final String name,
-          @PathParam("type") final String type) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("name") final String name,
+      @PathParam("type") final String type) {
 
     try {
       final Accept acceptType = Accept.parse(accept, version);
@@ -916,12 +918,12 @@ public abstract class AbstractServices {
 
       final String basePath = name + File.separatorChar;
       final StringBuilder path = new StringBuilder(name).
-              append(File.separatorChar).append(type).
-              append(File.separatorChar);
+          append(File.separatorChar).append(type).
+          append(File.separatorChar);
 
       path.append(metadata.getEntitySet(name).isSingleton()
-              ? Constants.get(version, ConstantKey.ENTITY)
-              : Constants.get(version, ConstantKey.FEED));
+          ? Constants.get(version, ConstantKey.ENTITY)
+          : Constants.get(version, ConstantKey.FEED));
 
       final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
       return xml.createResponse(null, feed, Commons.getETag(basePath, version), acceptType);
@@ -945,16 +947,16 @@ public abstract class AbstractServices {
   @GET
   @Path("/{name}")
   public Response getEntitySet(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("name") final String name,
-          @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
-          @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
-          @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
-          @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
-          @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("name") final String name,
+      @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
+      @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
+      @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
+      @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
+      @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
 
     try {
       final Accept acceptType;
@@ -982,19 +984,19 @@ public abstract class AbstractServices {
 
         if (StringUtils.isNotBlank(orderby)) {
           builder.append(Constants.get(version, ConstantKey.ORDERBY)).append(File.separatorChar).
-                  append(orderby).append(File.separatorChar);
+              append(orderby).append(File.separatorChar);
         }
 
         if (StringUtils.isNotBlank(filter)) {
           builder.append(Constants.get(version, ConstantKey.FILTER)).append(File.separatorChar).
-                  append(filter.replaceAll("/", "."));
+              append(filter.replaceAll("/", "."));
         } else if (StringUtils.isNotBlank(skiptoken)) {
           builder.append(Constants.get(version, ConstantKey.SKIP_TOKEN)).append(File.separatorChar).
-                  append(skiptoken);
+              append(skiptoken);
         } else {
           builder.append(metadata.getEntitySet(name).isSingleton()
-                  ? Constants.get(version, ConstantKey.ENTITY)
-                  : Constants.get(version, ConstantKey.FEED));
+              ? Constants.get(version, ConstantKey.ENTITY)
+              : Constants.get(version, ConstantKey.FEED));
         }
 
         final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
@@ -1032,10 +1034,10 @@ public abstract class AbstractServices {
         writer.close();
 
         return xml.createResponse(
-                location,
-                new ByteArrayInputStream(content.toByteArray()),
-                Commons.getETag(basePath, version),
-                acceptType);
+            location,
+            new ByteArrayInputStream(content.toByteArray()),
+            Commons.getETag(basePath, version),
+            acceptType);
       }
     } catch (Exception e) {
       return xml.createFaultResponse(accept, e);
@@ -1047,29 +1049,29 @@ public abstract class AbstractServices {
   @GET
   @Path("/Person({entityId})")
   public Response getPerson(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
     final Response internal = getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Person", entityId, format, null, null);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Person", entityId, format, null, null);
     if (internal.getStatus() == 200) {
       InputStream entity = (InputStream) internal.getEntity();
       try {
         if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
           entity = utils.getValue().addOperation(entity, "Sack", "#DefaultContainer.Sack",
-                  uriInfo.getAbsolutePath().toASCIIString()
+              uriInfo.getAbsolutePath().toASCIIString()
                   + "/Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee/Sack");
         }
 
         return utils.getValue().createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                entity,
-                internal.getHeaderString("ETag"),
-                utils.getKey());
+            uriInfo.getRequestUri().toASCIIString(),
+            entity,
+            internal.getHeaderString("ETag"),
+            utils.getKey());
       } catch (Exception e) {
         LOG.error("Error retrieving entity", e);
         return xml.createFaultResponse(accept, e);
@@ -1082,29 +1084,29 @@ public abstract class AbstractServices {
   @GET
   @Path("/Product({entityId})")
   public Response getProduct(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
     final Response internal = getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "Product", entityId, format, null, null);
+        uriInfo.getRequestUri().toASCIIString(), accept, "Product", entityId, format, null, null);
     if (internal.getStatus() == 200) {
       InputStream entity = (InputStream) internal.getEntity();
       try {
         if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
           entity = utils.getValue().addOperation(entity,
-                  "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions",
-                  uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions");
+              "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions",
+              uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions");
         }
 
         return utils.getValue().createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                entity,
-                internal.getHeaderString("ETag"),
-                utils.getKey());
+            uriInfo.getRequestUri().toASCIIString(),
+            entity,
+            internal.getHeaderString("ETag"),
+            utils.getKey());
       } catch (Exception e) {
         LOG.error("Error retrieving entity", e);
         return xml.createFaultResponse(accept, e);
@@ -1117,29 +1119,29 @@ public abstract class AbstractServices {
   @GET
   @Path("/ComputerDetail({entityId})")
   public Response getComputerDetail(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
 
     final Response internal = getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, "ComputerDetail", entityId, format, null, null);
+        uriInfo.getRequestUri().toASCIIString(), accept, "ComputerDetail", entityId, format, null, null);
     if (internal.getStatus() == 200) {
       InputStream entity = (InputStream) internal.getEntity();
       try {
         if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
           entity = utils.getValue().addOperation(entity,
-                  "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications",
-                  uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications");
+              "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications",
+              uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications");
         }
 
         return utils.getValue().createResponse(
-                uriInfo.getRequestUri().toASCIIString(),
-                entity,
-                internal.getHeaderString("ETag"),
-                utils.getKey());
+            uriInfo.getRequestUri().toASCIIString(),
+            entity,
+            internal.getHeaderString("ETag"),
+            utils.getKey());
       } catch (Exception e) {
         LOG.error("Error retrieving entity", e);
         return xml.createFaultResponse(accept, e);
@@ -1163,26 +1165,26 @@ public abstract class AbstractServices {
   @GET
   @Path("/{entitySetName}({entityId})")
   public Response getEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand,
-          @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand,
+      @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) {
 
     return getEntityInternal(
-            uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select);
+        uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select);
   }
 
   protected Response getEntityInternal(
-          final String location,
-          final String accept,
-          final String entitySetName,
-          final String entityId,
-          final String format,
-          String expand,
-          final String select) {
+      final String location,
+      final String accept,
+      final String entitySetName,
+      final String entityId,
+      final String format,
+      String expand,
+      final String select) {
 
     try {
       final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -1192,15 +1194,15 @@ public abstract class AbstractServices {
       }
 
       final Map.Entry<String, InputStream> entityInfo =
-              utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM);
+          utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM);
 
       final InputStream entity = entityInfo.getValue();
 
       ResWrap<Entity> container = atomDeserializer.toEntity(entity);
       if (container.getContextURL() == null) {
         container = new ResWrap<Entity>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
-                + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
-                container.getMetadataETag(), container.getPayload());
+            + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
+            container.getMetadataETag(), container.getPayload());
       }
       final Entity entry = container.getPayload();
 
@@ -1253,12 +1255,12 @@ public abstract class AbstractServices {
             if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_ENTRY))) {
               // inline entry
               final Entity inline = atomDeserializer.toEntity(
-                      xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
+                  xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
               rep.setInlineEntity(inline);
             } else if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_FEED))) {
               // inline feed
               final EntitySet inline = atomDeserializer.toEntitySet(
-                      xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
+                  xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
               rep.setInlineEntitySet(inline);
             }
             replace.put(link, rep);
@@ -1272,10 +1274,10 @@ public abstract class AbstractServices {
       }
 
       return xml.createResponse(
-              location,
-              xml.writeEntity(utils.getKey(), container),
-              Commons.getETag(entityInfo.getKey(), version),
-              utils.getKey());
+          location,
+          xml.writeEntity(utils.getKey(), container),
+          Commons.getETag(entityInfo.getKey(), version),
+          utils.getKey());
     } catch (Exception e) {
       LOG.error("Error retrieving entity", e);
       return xml.createFaultResponse(accept, e);
@@ -1285,10 +1287,10 @@ public abstract class AbstractServices {
   @GET
   @Path("/{entitySetName}({entityId})/$value")
   public Response getMediaEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId) {
 
     try {
       if (!accept.contains("*/*") && !accept.contains("application/octet-stream")) {
@@ -1298,10 +1300,10 @@ public abstract class AbstractServices {
       final AbstractUtilities utils = getUtilities(null);
       final Map.Entry<String, InputStream> entityInfo = utils.readMediaEntity(entitySetName, entityId);
       return utils.createResponse(
-              uriInfo.getRequestUri().toASCIIString(),
-              entityInfo.getValue(),
-              Commons.getETag(entityInfo.getKey(), version),
-              null);
+          uriInfo.getRequestUri().toASCIIString(),
+          entityInfo.getValue(),
+          Commons.getETag(entityInfo.getKey(), version),
+          null);
 
     } catch (Exception e) {
       LOG.error("Error retrieving entity", e);
@@ -1312,8 +1314,8 @@ public abstract class AbstractServices {
   @DELETE
   @Path("/{entitySetName}({entityId})")
   public Response removeEntity(
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId) {
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId) {
 
     try {
       final String basePath = entitySetName + File.separatorChar + Commons.getEntityKey(entityId);
@@ -1327,16 +1329,16 @@ public abstract class AbstractServices {
   }
 
   private Response replaceProperty(
-          final String location,
-          final String accept,
-          final String contentType,
-          final String prefer,
-          final String entitySetName,
-          final String entityId,
-          final String path,
-          final String format,
-          final String changes,
-          final boolean justValue) {
+      final String location,
+      final String accept,
+      final String contentType,
+      final String prefer,
+      final String entitySetName,
+      final String entityId,
+      final String path,
+      final String format,
+      final String changes,
+      final boolean justValue) {
 
     // if the given path is not about any link then search for property
     LOG.info("Retrieve property {}", path);
@@ -1346,7 +1348,7 @@ public abstract class AbstractServices {
       final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
 
       final ResWrap<Entity> container = xml.readContainerEntity(Accept.ATOM,
-              fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
+          fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
 
       final Entity entry = container.getPayload();
 
@@ -1355,7 +1357,7 @@ public abstract class AbstractServices {
         if (toBeReplaced == null) {
           toBeReplaced = entry.getProperty(element.trim());
         } else {
-          List<Property> value = toBeReplaced.asComplex();
+          List<Property> value = toBeReplaced.asComplex().getValue();
           for (Property field : value) {
             if (field.getName().equalsIgnoreCase(element)) {
               toBeReplaced = field;
@@ -1373,14 +1375,14 @@ public abstract class AbstractServices {
         toBeReplaced.setValue(ValueType.PRIMITIVE, changes);
       } else {
         final Property pchanges = xml.readProperty(
-                Accept.parse(contentType, version),
-                IOUtils.toInputStream(changes, Constants.ENCODING));
+            Accept.parse(contentType, version),
+            IOUtils.toInputStream(changes, Constants.ENCODING));
 
         toBeReplaced.setValue(pchanges.getValueType(), pchanges.getValue());
       }
 
       fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
-              fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
+          fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1397,7 +1399,7 @@ public abstract class AbstractServices {
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -1407,12 +1409,12 @@ public abstract class AbstractServices {
   }
 
   private Response deletePropertyValue(
-          final String accept,
-          final String prefer,
-          final String entitySetName,
-          final String entityId,
-          final String path,
-          final String format) {
+      final String accept,
+      final String prefer,
+      final String entitySetName,
+      final String entityId,
+      final String path,
+      final String format) {
     try {
       Accept acceptType = null;
       if (StringUtils.isNotBlank(format)) {
@@ -1427,10 +1429,10 @@ public abstract class AbstractServices {
       final AbstractUtilities utils = getUtilities(acceptType);
 
       final InputStream changed = utils.deleteProperty(
-              entitySetName,
-              entityId,
-              Arrays.asList(path.split("/")),
-              acceptType);
+          entitySetName,
+          entityId,
+          Arrays.asList(path.split("/")),
+          acceptType);
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1441,7 +1443,7 @@ public abstract class AbstractServices {
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -1465,18 +1467,18 @@ public abstract class AbstractServices {
   @PUT
   @Path("/{entitySetName}({entityId})/{path:.*}/$value")
   public Response replacePropertyValue(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String changes) {
 
     return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
-            accept, contentType, prefer, entitySetName, entityId, path, format, changes, true);
+        accept, contentType, prefer, entitySetName, entityId, path, format, changes, true);
   }
 
   /**
@@ -1493,18 +1495,18 @@ public abstract class AbstractServices {
   @MERGE
   @Path("/{entitySetName}({entityId})/{path:.*}")
   public Response mergeProperty(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String changes) {
 
     return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
-            accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+        accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
   }
 
   /**
@@ -1521,37 +1523,37 @@ public abstract class AbstractServices {
   @PATCH
   @Path("/{entitySetName}({entityId})/{path:.*}")
   public Response patchProperty(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String changes) {
 
     return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
-            accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+        accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
   }
 
   @PUT
-  @Produces({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
-  @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM})
+  @Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+  @Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM })
   @Path("/{entitySetName}({entityId})/$value")
   public Response replaceMediaEntity(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String value) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String value) {
     try {
 
       final AbstractUtilities utils = getUtilities(null);
 
       final InputStream res = utils.putMediaInMemory(
-              entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING));
+          entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING));
 
       final String location = uriInfo.getRequestUri().toASCIIString().replace("/$value", "");
 
@@ -1564,7 +1566,7 @@ public abstract class AbstractServices {
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -1589,36 +1591,36 @@ public abstract class AbstractServices {
   @PUT
   @Path("/{entitySetName}({entityId})/{path:.*}")
   public Response replaceProperty(
-          @Context final UriInfo uriInfo,
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
-          final String changes) {
+      @Context final UriInfo uriInfo,
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+      final String changes) {
 
     if (xml.isMediaContent(entitySetName + "/" + path)) {
       return replaceMediaProperty(prefer, entitySetName, entityId, path, changes);
     } else {
       return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
-              accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+          accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
     }
   }
 
   private Response replaceMediaProperty(
-          final String prefer,
-          final String entitySetName,
-          final String entityId,
-          final String path,
-          final String value) {
+      final String prefer,
+      final String entitySetName,
+      final String entityId,
+      final String path,
+      final String value) {
 
     try {
       final AbstractUtilities utils = getUtilities(null);
 
       InputStream res = utils.putMediaInMemory(
-              entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING));
+          entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING));
 
       final Response response;
       if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1629,7 +1631,7 @@ public abstract class AbstractServices {
       }
 
       if (StringUtils.isNotBlank(prefer)) {
-        response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
+        response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
       }
 
       return response;
@@ -1652,12 +1654,12 @@ public abstract class AbstractServices {
   @DELETE
   @Path("/{entitySetName}({entityId})/{path:.*}/$value")
   public Response deleteProperty(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
     return deletePropertyValue(accept, prefer, entitySetName, entityId, path, format);
   }
 
@@ -1674,11 +1676,11 @@ public abstract class AbstractServices {
   @GET
   @Path("/{entitySetName}({entityId})/{path:.*}/$value")
   public Response getPathValue(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     try {
       Accept acceptType = null;
@@ -1707,11 +1709,11 @@ public abstract class AbstractServices {
   @GET
   @Path("/{entitySetName}({entityId})/{path:.*}")
   public Response getPath(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entitySetName") final String entitySetName,
-          @PathParam("entityId") final String entityId,
-          @PathParam("path") final String path,
-          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entitySetName") final String entitySetName,
+      @PathParam("entityId") final String entityId,
+      @PathParam("path") final String path,
+      @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
 
     // default utilities
     final AbstractUtilities utils = xml;
@@ -1736,7 +1738,7 @@ public abstract class AbstractServices {
           final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
 
           final ResWrap<?> container = linkInfo.isFeed() ? atomDeserializer.toEntitySet(stream) : atomDeserializer.
-                  toEntity(stream);
+              toEntity(stream);
           if (acceptType == Accept.ATOM) {
             atomSerializer.write(writer, container);
           } else {
@@ -1748,10 +1750,10 @@ public abstract class AbstractServices {
           final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
 
           return xml.createResponse(
-                  null,
-                  new ByteArrayInputStream(content.toByteArray()),
-                  Commons.getETag(basePath, version),
-                  acceptType);
+              null,
+              new ByteArrayInputStream(content.toByteArray()),
+              Commons.getETag(basePath, version),
+              acceptType);
 
         } catch (NotFoundException e) {
           // if the given path is not about any link then search for property
@@ -1764,9 +1766,9 @@ public abstract class AbstractServices {
   }
 
   private Response navigateStreamedEntity(
-          final String entitySetName,
-          final String entityId,
-          final String path) throws Exception {
+      final String entitySetName,
+      final String entityId,
+      final String path) throws Exception {
 
     final AbstractUtilities utils = getUtilities(null);
     final Map.Entry<String, InputStream> entityInfo = utils.readMediaEntity(entitySetName, entityId, path);
@@ -1774,11 +1776,11 @@ public abstract class AbstractServices {
   }
 
   private Response navigateProperty(
-          final Accept acceptType,
-          final String entitySetName,
-          final String entityId,
-          final String path,
-          final boolean searchForValue) throws Exception {
+      final Accept acceptType,
+      final String entitySetName,
+      final String entityId,
+      final String path,
+      final boolean searchForValue) throws Exception {
 
     if ((searchForValue && acceptType != null && acceptType != Accept.TEXT) || acceptType == Accept.ATOM) {
       throw new UnsupportedMediaTypeException("Unsupported media type " + acceptType);
@@ -1795,11 +1797,11 @@ public abstract class AbstractServices {
     final String[] pathElems = StringUtils.split(path, "/");
     Property property = entryContainer.getPayload().getProperty(pathElems[0]);
     if (pathElems.length > 1 && property.isComplex()) {
-      for (Property sub : property.asComplex()) {
+      for (Property sub : property.asComplex().getValue()) {
         if (pathElems[1].equals(sub.getName())) {
           property = sub;
           if (pathElems.length > 2 && property.isComplex()) {
-            for (Property subsub : property.asComplex()) {
+            for (Property subsub : property.asComplex().getValue()) {
               if (pathElems[2].equals(subsub.getName())) {
                 property = subsub;
               }
@@ -1810,25 +1812,25 @@ public abstract class AbstractServices {
     }
 
     final ResWrap<Property> container = new ResWrap<Property>(
-            URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+        URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
             + (version.compareTo(ODataServiceVersion.V40) >= 0 ? entitySetName + "(" + entityId + ")/" + path
-            : property.getType())),
-            entryContainer.getMetadataETag(),
-            property);
+                : property.getType())),
+        entryContainer.getMetadataETag(),
+        property);
 
     return xml.createResponse(null,
-            searchForValue ? IOUtils.toInputStream(
+        searchForValue ? IOUtils.toInputStream(
             container.getPayload().isNull() ? StringUtils.EMPTY : stringValue(container.getPayload()),
             Constants.ENCODING) : utils.writeProperty(acceptType, container),
-            Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version),
-            acceptType);
+        Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version),
+        acceptType);
   }
 
   private String stringValue(final Property property) {
     EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOfFQN(version, property.getType());
     try {
       return EdmPrimitiveTypeFactory.getInstance(kind)
-              .valueToString(property.asPrimitive(), null, null,
+          .valueToString(property.asPrimitive(), null, null,
               org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION,
               org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null);
     } catch (final EdmPrimitiveTypeException e) {
@@ -1846,8 +1848,8 @@ public abstract class AbstractServices {
   @GET
   @Path("/{entitySetName}/$count")
   public Response count(
-          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
-          @PathParam("entitySetName") final String entitySetName) {
+      @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+      @PathParam("entitySetName") final String entitySetName) {
     try {
       final Accept acceptType = Accept.parse(accept, version, Accept.TEXT);
 
@@ -1908,15 +1910,15 @@ public abstract class AbstractServices {
         alink.getAnnotations().addAll(property.getAnnotations());
 
         alink.setType(navProperties.get(property.getName()).isEntitySet()
-                ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
-                : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
+            ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
+            : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
 
         alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName());
 
         if (property.isComplex()) {
           Entity inline = new EntityImpl();
           inline.setType(navProperties.get(property.getName()).getType());
-          for (Property prop : property.asComplex()) {
+          for (Property prop : property.asComplex().getValue()) {
             inline.getProperties().add(prop);
           }
           alink.setInlineEntity(inline);
@@ -1926,8 +1928,7 @@ public abstract class AbstractServices {
           for (Object value : property.asCollection()) {
             Entity inlineEntity = new EntityImpl();
             inlineEntity.setType(navProperties.get(property.getName()).getType());
-            for (Property prop : (value instanceof LinkedComplexValue ? ((LinkedComplexValue) value).getValue()
-                    : ((Valuable) value).asComplex())) {
+            for (Property prop : ((ComplexValue) value).getValue()) {
               inlineEntity.getProperties().add(prop);
             }
             inline.getEntities().add(inlineEntity);
@@ -1965,8 +1966,8 @@ public abstract class AbstractServices {
         final LinkImpl link = new LinkImpl();
         link.setTitle(property.getKey());
         link.setType(property.getValue().isEntitySet()
-                ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
-                : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
+            ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
+            : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
         link.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getKey());
         link.setHref(entitySetName + "(" + entityKey + ")/" + property.getKey());
         entry.getNavigationLinks().add(link);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 6af5e2e..9ae4648 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -1310,10 +1310,10 @@ public class V4Services extends AbstractServices {
       }
 
       assert property.isComplex();
-      assert 1 == property.asComplex().size();
-      assert "Edm.Int32".equals(property.asComplex().get(0).getType());
-      assert property.asComplex().get(0).isPrimitive();
-      assert "percentage".equals(property.asComplex().get(0).getName());
+      assert 1 == property.asComplex().getValue().size();
+      assert "Edm.Int32".equals(property.asComplex().getValue().get(0).getType());
+      assert property.asComplex().getValue().get(0).isPrimitive();
+      assert "percentage".equals(property.asComplex().getValue().get(0).getName());
 
       return xml.createResponse(null, null, null, acceptType, Response.Status.NO_CONTENT);
     } catch (Exception e) {


[2/3] olingo-odata4 git commit: [OLINGO-575] Start merging ComplexValue and LinkedComplexValue

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 806bbc6..8ebaa1b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -51,10 +51,10 @@ import org.apache.olingo.client.api.edm.xml.Reference;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataError;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
@@ -295,9 +295,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
     final ODataObjectFactory factory = client.getObjectFactory();
     ODataEntity patchEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETCompComp"));
     patchEntity.getProperties().add(factory.newComplexProperty("PropertyComp",
-        factory.newLinkedComplexValue("olingo.odata.test1.CTCompComp").add(
+        factory.newComplexValue("olingo.odata.test1.CTCompComp").add(
             factory.newComplexProperty("PropertyComp",
-                factory.newLinkedComplexValue("olingo.odata.test1.CTTwoPrim").add(
+                factory.newComplexValue("olingo.odata.test1.CTTwoPrim").add(
                     factory.newPrimitiveProperty("PropertyInt16",
                         factory.newPrimitiveValueBuilder().buildInt32(42)))))));
     final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESCompComp").appendKeySegment(1).build();
@@ -314,8 +314,8 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
     final ODataEntity entity = entityResponse.getBody();
     assertNotNull(entity);
-    final ODataLinkedComplexValue complex = entity.getProperty("PropertyComp").getLinkedComplexValue()
-        .get("PropertyComp").getLinkedComplexValue();
+    final ODataComplexValue complex = entity.getProperty("PropertyComp").getComplexValue()
+        .get("PropertyComp").getComplexValue();
     assertNotNull(complex);
     final ODataProperty property1 = complex.get("PropertyInt16");
     assertNotNull(property1);
@@ -358,8 +358,8 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
     final ODataEntity entity = entityResponse.getBody();
     assertNotNull(entity);
-    final ODataLinkedComplexValue complex = entity.getProperty("PropertyCompComp").getLinkedComplexValue()
-        .get("PropertyComp").getLinkedComplexValue();
+    final ODataComplexValue complex = entity.getProperty("PropertyCompComp").getComplexValue()
+        .get("PropertyComp").getComplexValue();
     assertNotNull(complex);
     final ODataProperty property = complex.get("PropertyInt16");
     assertNotNull(property);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
index a8ef9f3..0e456ba 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java
@@ -321,8 +321,8 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
     final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses =
         client.getObjectFactory().
             newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)");
-    final ODataComplexValue<ODataProperty> address = client.getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = client.getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa")));
     address.add(client.getObjectFactory().newPrimitiveProperty("City",
@@ -411,8 +411,8 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
     final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses =
         edmClient.getObjectFactory().
             newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)");
-    final ODataComplexValue<ODataProperty> address = edmClient.getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = edmClient.getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(edmClient.getObjectFactory().newPrimitiveProperty("Street",
         edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa")));
     address.add(edmClient.getObjectFactory().newPrimitiveProperty("City",

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
index b7e2c15..fcc1f61 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java
@@ -18,6 +18,12 @@
  */
 package org.apache.olingo.fit.v4;
 
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.TimeZone;
+
 import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -27,19 +33,12 @@ import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValuable;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.junit.Test;
 
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import static org.junit.Assert.assertEquals;
-
 public class DerivedTypeTestITCase extends AbstractTestITCase {
 
   private void read(final ODataFormat format) {
@@ -89,7 +88,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
     customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test")));
 
-    final ODataComplexValue<ODataProperty> homeAddress =
+    final ODataComplexValue homeAddress =
         client.getObjectFactory().newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress");
     homeAddress.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("V.le Gabriele D'Annunzio")));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
index 1a3c14f..4721ddc 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java
@@ -18,13 +18,20 @@
  */
 package org.apache.olingo.fit.v4;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.UUID;
+
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmSchema;
@@ -32,14 +39,6 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.junit.Test;
 
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 public class OpenTypeTestITCase extends AbstractTestITCase {
 
   @Test
@@ -115,7 +114,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
         getClient().getObjectFactory().newEnumProperty("aColor", getClient().getObjectFactory().
             newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
 
-    final ODataComplexValue<ODataProperty> contactDetails = getClient().getObjectFactory().newComplexValue(
+    final ODataComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
         "Microsoft.Test.OData.Services.OpenTypesServiceV4.ContactDetails");
     contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("FirstContacted",
         getClient().getObjectFactory().newPrimitiveValueBuilder().buildBinary("text".getBytes())));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
index 940ba4b..261d943 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java
@@ -18,6 +18,14 @@
  */
 package org.apache.olingo.fit.v4;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
 import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
@@ -32,14 +40,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.junit.Test;
 
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 public class OperationImportInvokeTestITCase extends AbstractTestITCase {
 
   private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
@@ -68,8 +68,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
     assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
 
     // GetPerson
-    final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = getClient().getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
     address.add(client.getObjectFactory().newPrimitiveProperty("City",
@@ -144,8 +144,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
     assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
 
     // GetPerson
-    final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = getClient().getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
     address.add(client.getObjectFactory().newPrimitiveProperty("City",
@@ -194,8 +194,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
     assertNotNull(discount);
 
     // ResetBossAddress
-    final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = getClient().getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
     address.add(client.getObjectFactory().newPrimitiveProperty("City",
@@ -234,8 +234,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
     assertNotNull(discount);
 
     // ResetBossAddress
-    final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
-        newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
+    final ODataComplexValue address = getClient().getObjectFactory().
+        newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
     address.add(client.getObjectFactory().newPrimitiveProperty("Street",
         client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
     address.add(client.getObjectFactory().newPrimitiveProperty("City",

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index b23878b..8234368 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -35,6 +35,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotatable;
 import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.DeletedEntity;
 import org.apache.olingo.commons.api.data.Delta;
@@ -43,7 +44,6 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
-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;
@@ -62,7 +62,6 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.ODataLinked;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
@@ -89,10 +88,10 @@ import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.serialization.ODataSerializerException;
 import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.domain.ODataAnnotationImpl;
 import org.apache.olingo.commons.core.domain.ODataDeletedEntityImpl;
@@ -165,15 +164,12 @@ public class ODataBinderImpl implements ODataBinder {
       propertyResource.setValue(ValueType.ENUM, propertyValue);
     } else if (odataValuable.hasComplexValue()) {
       propertyResource.setType(odataValuable.getComplexValue().getTypeName());
-      propertyResource.setValue(
-          propertyValue instanceof LinkedComplexValue ? ValueType.LINKED_COMPLEX : ValueType.COMPLEX,
-          propertyValue);
+      propertyResource.setValue(ValueType.COMPLEX, propertyValue);
     } else if (odataValuable.hasCollectionValue()) {
-      final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> collectionValue =
+      final ODataCollectionValue<ODataValue> collectionValue =
           odataValuable.getCollectionValue();
       propertyResource.setType(collectionValue.getTypeName());
-      final org.apache.olingo.commons.api.domain.ODataValue value =
-          collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null;
+      final ODataValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null;
       ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
       if (value == null) {
         valueType = ValueType.COLLECTION_PRIMITIVE;
@@ -182,8 +178,6 @@ public class ODataBinderImpl implements ODataBinder {
             ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE;
       } else if (value.isEnum()) {
         valueType = ValueType.COLLECTION_ENUM;
-      } else if (value.isLinkedComplex()) {
-        valueType = ValueType.COLLECTION_LINKED_COMPLEX;
       } else if (value.isComplex()) {
         valueType = ValueType.COLLECTION_COMPLEX;
       }
@@ -343,58 +337,35 @@ public class ODataBinderImpl implements ODataBinder {
     return propertyResource;
   }
 
-  // TODO: Refactor away the v3 code
-  @SuppressWarnings("unchecked")
   protected Object getValue(final ODataValue value) {
-    Object valueResource;
-    if (value instanceof org.apache.olingo.commons.api.domain.ODataValue
-        && ((org.apache.olingo.commons.api.domain.ODataValue) value).isEnum()) {
-
-      valueResource =
-          ((org.apache.olingo.commons.api.domain.ODataValue) value).asEnum().getValue();
-    } else {
-      valueResource = getValueInternal(value);
-
-      if (value instanceof org.apache.olingo.commons.api.domain.ODataValue
-          && ((org.apache.olingo.commons.api.domain.ODataValue) value).isLinkedComplex()) {
-
-        final LinkedComplexValue lcValueResource = new LinkedComplexValueImpl();
-        lcValueResource.getValue().addAll((List<Property>) valueResource);
-
-        final ODataLinkedComplexValue linked =
-            ((org.apache.olingo.commons.api.domain.ODataValue) value).asLinkedComplex();
-        annotations(linked, lcValueResource);
-        links(linked, lcValueResource);
-
-        valueResource = lcValueResource;
-      }
-    }
-    return valueResource;
-  }
-
-  protected Object getValueInternal(final ODataValue value) {
+    Object valueResource = null;
     if (value == null) {
-      return null;
+      valueResource = null;
+    } else if (value.isEnum()) {
+      valueResource = value.asEnum().getValue();
     } else if (value.isPrimitive()) {
-      return value.asPrimitive().toValue();
+      valueResource = value.asPrimitive().toValue();
     } else if (value.isComplex()) {
-      final ODataComplexValue<? extends ODataProperty> _value = value.asComplex();
-      List<Property> valueResource = new ArrayList<Property>();
-
-      for (final ODataProperty propertyValue : _value) {
-        valueResource.add(getProperty(propertyValue));
+      List<Property> complexProperties = new ArrayList<Property>();
+      for (final ODataProperty propertyValue : value.asComplex()) {
+        complexProperties.add(getProperty(propertyValue));
       }
-      return valueResource;
+      final ComplexValue lcValueResource = new ComplexValueImpl();
+      lcValueResource.getValue().addAll(complexProperties);
+      annotations(value.asComplex(), lcValueResource);
+      links(value.asComplex(), lcValueResource);
+      valueResource = lcValueResource;
+      
     } else if (value.isCollection()) {
       final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
-      ArrayList<Object> valueResource = new ArrayList<Object>();
+      ArrayList<Object> lcValueResource = new ArrayList<Object>();
 
       for (final ODataValue collectionValue : _value) {
-        valueResource.add(getValue(collectionValue));
+        lcValueResource.add(getValue(collectionValue));
       }
-      return valueResource;
+      valueResource = lcValueResource;
     }
-    return null;
+    return valueResource;
   }
 
   private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatable odataAnnotatable) {
@@ -604,17 +575,14 @@ public class ODataBinderImpl implements ODataBinder {
       for (final Object inlined : property.asCollection()) {
         Entity inlineEntity = new EntityImpl();
         inlineEntity.setType(propertyTypeName);
-        inlineEntity.getProperties().addAll(
-            inlined instanceof LinkedComplexValue ? ((LinkedComplexValue) inlined).getValue() :
-                inlined instanceof Property ? ((Property) inlined).asComplex() : null);
+        inlineEntity.getProperties().addAll(((ComplexValue) inlined).getValue());
         inlineEntitySet.getEntities().add(inlineEntity);
       }
       return createODataInlineEntitySet(inlineEntitySet, null, property.getName(), null);
     } else {
       Entity inlineEntity = new EntityImpl();
       inlineEntity.setType(propertyTypeName);
-      inlineEntity.getProperties().addAll(
-          property.isLinkedComplex() ? property.asLinkedComplex().getValue() : property.asComplex());
+      inlineEntity.getProperties().addAll(property.asComplex().getValue());
       return createODataInlineEntity(inlineEntity, null, property.getName(), null);
     }
   }
@@ -777,16 +745,16 @@ public class ODataBinderImpl implements ODataBinder {
     if (valuable.isEnum()) {
       value = ((ODataClient) client).getObjectFactory().newEnumValue(type == null ? null : type.toString(),
           valuable.asEnum().toString());
-    } else if (valuable.isLinkedComplex()) {
-      final ODataLinkedComplexValue lcValue =
-          ((ODataClient) client).getObjectFactory().newLinkedComplexValue(type == null ? null : type.toString());
+    } else if (valuable.isComplex()) {
+      final ODataComplexValue lcValue =
+          ((ODataClient) client).getObjectFactory().newComplexValue(type == null ? null : type.toString());
 
       EdmComplexType edmType = null;
       if (client instanceof EdmEnabledODataClient && type != null) {
         edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type);
       }
 
-      for (Property property : valuable.asLinkedComplex().getValue()) {
+      for (Property property : valuable.asComplex().getValue()) {
         EdmType edmPropertyType = null;
         if (edmType != null) {
           final EdmElement edmProp = edmType.getProperty(property.getName());
@@ -797,8 +765,8 @@ public class ODataBinderImpl implements ODataBinder {
         lcValue.add(getODataProperty(edmPropertyType, property));
       }
 
-      odataNavigationLinks(edmType, valuable.asLinkedComplex(), lcValue, metadataETag, contextURL);
-      odataAnnotations(valuable.asLinkedComplex(), lcValue);
+      odataNavigationLinks(edmType, valuable.asComplex(), lcValue, metadataETag, contextURL);
+      odataAnnotations(valuable.asComplex(), lcValue);
 
       value = lcValue;
     } else {
@@ -838,9 +806,8 @@ public class ODataBinderImpl implements ODataBinder {
                 : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).
             build();
       } else if (valuable.isComplex()) {
-        final ODataComplexValue<ODataProperty> cValue =
-            (ODataComplexValue<ODataProperty>) client.getObjectFactory().
-                newComplexValue(type == null ? null : type.toString());
+        final ODataComplexValue cValue = (ODataComplexValue) client.getObjectFactory().
+            newComplexValue(type == null ? null : type.toString());
 
         if (!valuable.isNull()) {
           EdmComplexType edmType = null;
@@ -848,7 +815,7 @@ public class ODataBinderImpl implements ODataBinder {
             edmType = ((EdmEnabledODataClient) client).getEdm(metadataETag).getComplexType(type);
           }
 
-          for (Property property : valuable.asComplex()) {
+          for (Property property : valuable.asComplex().getValue()) {
             EdmType edmPropertyType = null;
             if (edmType != null) {
               final EdmElement edmProp = edmType.getProperty(property.getName());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index 2b2882e..c5960a9 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -34,11 +34,11 @@ import org.apache.olingo.client.core.EdmEnabledODataClientImpl;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValuable;
 import org.apache.olingo.commons.api.domain.ODataValue;
@@ -287,7 +287,7 @@ public class EntityTest extends AbstractTest {
             getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
-    final ODataLinkedComplexValue addressValue = entity.getProperty("Address").getLinkedComplexValue();
+    final ODataComplexValue addressValue = entity.getProperty("Address").getComplexValue();
     assertNotNull(addressValue);
     assertNotNull(addressValue.getNavigationLink("Country"));
 
@@ -336,7 +336,7 @@ public class EntityTest extends AbstractTest {
     assertEquals("com.contoso.display.styleType", annotation.getValue().getTypeName());
     assertTrue(annotation.hasComplexValue());
     assertEquals(2,
-            annotation.getValue().asLinkedComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
+            annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
             new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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 3a107a4..170e686 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
@@ -22,10 +22,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
 import java.io.ByteArrayInputStream;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -42,13 +38,16 @@ import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.junit.Test;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
 public class JSONTest extends AbstractTest {
 
   private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@@ -219,7 +218,7 @@ public class JSONTest extends AbstractTest {
     assertTrue(property.isPrimitive());
     property = delta.getEntities().get(1).getProperty("ShippingAddress");
     assertNotNull(property);
-    assertTrue(property.isLinkedComplex());
+    assertTrue(property.isComplex());
   }
 
   @Test
@@ -232,7 +231,7 @@ public class JSONTest extends AbstractTest {
     final ODataEntity message = getClient().getObjectFactory().
             newEntity(new FullQualifiedName("Microsoft.Exchange.Services.OData.Model.Message"));
 
-    final ODataComplexValue<ODataProperty> toRecipient = getClient().getObjectFactory().
+    final ODataComplexValue toRecipient = getClient().getObjectFactory().
             newComplexValue("Microsoft.Exchange.Services.OData.Model.Recipient");
     toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Name",
             getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challen_olingo_client")));
@@ -243,7 +242,7 @@ public class JSONTest extends AbstractTest {
     toRecipients.add(toRecipient);
     message.getProperties().add(getClient().getObjectFactory().newCollectionProperty("ToRecipients", toRecipients));
 
-    final ODataComplexValue<ODataProperty> body =
+    final ODataComplexValue body =
             getClient().getObjectFactory().newComplexValue("Microsoft.Exchange.Services.OData.Model.ItemBody");
     body.add(getClient().getObjectFactory().newPrimitiveProperty("Content",
             getClient().getObjectFactory().newPrimitiveValueBuilder().

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
index 8de5e4f..642f37b 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PropertyTest.java
@@ -81,7 +81,7 @@ public class PropertyTest extends AbstractTest {
     final ODataProperty written = getClient().getReader().readProperty(
             getClient().getWriter().writeProperty(property, format), format);
     // This is needed because type information gets lost with JSON serialization
-    final ODataComplexValue<ODataProperty> typedValue = getClient().getObjectFactory().
+    final ODataComplexValue typedValue = getClient().getObjectFactory().
             newComplexValue(property.getComplexValue().getTypeName());
     for (final Iterator<ODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
       final ODataProperty prop = itor.next();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
new file mode 100644
index 0000000..ea5b528
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
@@ -0,0 +1,26 @@
+/*
+ * 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 Linked, Annotatable {
+
+  List<Property> getValue();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
deleted file mode 100644
index 9c15b70..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/LinkedComplexValue.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;
-
-import java.util.List;
-
-public interface LinkedComplexValue extends Linked, Annotatable {
-
-  List<Property> getValue();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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 3bd128d..ca660a8 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
@@ -38,8 +38,6 @@ public interface Valuable {
 
   boolean isComplex();
 
-  boolean isLinkedComplex();
-
   boolean isCollection();
 
   Object getValue();
@@ -50,9 +48,7 @@ public interface Valuable {
 
   Geospatial asGeospatial();
 
-  List<Property> asComplex();
-
-  LinkedComplexValue asLinkedComplex();
+  ComplexValue asComplex();
 
   List<?> asCollection();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
index 94fe139..7b6d942 100644
--- 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
@@ -19,12 +19,11 @@
 package org.apache.olingo.commons.api.data;
 
 public enum ValueType {
-  PRIMITIVE, GEOSPATIAL, ENUM, COMPLEX, LINKED_COMPLEX,
+  PRIMITIVE, GEOSPATIAL, ENUM, COMPLEX,
   COLLECTION_PRIMITIVE(PRIMITIVE),
   COLLECTION_GEOSPATIAL(GEOSPATIAL),
   COLLECTION_ENUM(ENUM),
-  COLLECTION_COMPLEX(COMPLEX),
-  COLLECTION_LINKED_COMPLEX(LINKED_COMPLEX);
+  COLLECTION_COMPLEX(COMPLEX);
 
   private final ValueType baseType;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
index 4f2470d..acd056d 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
@@ -77,10 +77,9 @@ public abstract class AbstractODataValue implements ODataValue {
    * 
    * @return complex value.
    */
-  @SuppressWarnings("unchecked")
   @Override
-  public <OP extends ODataProperty> ODataComplexValue<OP> asComplex() {
-    return isComplex() ? (ODataComplexValue<OP>) this : null;
+  public ODataComplexValue asComplex() {
+    return isComplex() ? (ODataComplexValue) this : null;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
index 13d1e4b..04888d7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
@@ -25,7 +25,7 @@ import java.util.Map;
  * 
  * @param <OP> The actual ODataProperty interface.
  */
-public interface ODataComplexValue<OP extends ODataProperty> extends ODataValue, Iterable<OP> {
+public interface ODataComplexValue extends ODataValue, ODataLinked, ODataAnnotatable, Iterable<ODataProperty> {
 
   /**
    * Adds field to the complex type.
@@ -33,7 +33,7 @@ public interface ODataComplexValue<OP extends ODataProperty> extends ODataValue,
    * @param field field to be added.
    * @return this (for fluent-style calls)
    */
-  ODataComplexValue<OP> add(OP field);
+  ODataComplexValue add(ODataProperty field);
 
   /**
    * Gets field.
@@ -41,7 +41,7 @@ public interface ODataComplexValue<OP extends ODataProperty> extends ODataValue,
    * @param name name of the field to be retrieved.
    * @return requested field.
    */
-  OP get(String name);
+  ODataProperty get(String name);
 
   /**
    * Gets number of fields.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkedComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkedComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkedComplexValue.java
deleted file mode 100644
index 3009c78..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkedComplexValue.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.domain;
-
-
-public interface ODataLinkedComplexValue
-    extends ODataValue, ODataLinked, ODataComplexValue<ODataProperty>, ODataAnnotatable {
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
index 90d6ed6..3dee5e3 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
@@ -111,9 +111,7 @@ public interface ODataObjectFactory {
 
   ODataEnumValue newEnumValue(String typeName, String value);
 
-  ODataComplexValue<ODataProperty> newComplexValue(String typeName);
-
-  ODataLinkedComplexValue newLinkedComplexValue(String typeName);
+  ODataComplexValue newComplexValue(String typeName);
 
   ODataCollectionValue<ODataValue> newCollectionValue(String typeName);
 
@@ -133,7 +131,7 @@ public interface ODataObjectFactory {
    * @param value value.
    * @return complex property.
    */
-  ODataProperty newComplexProperty(String name, ODataComplexValue<? extends ODataProperty> value);
+  ODataProperty newComplexProperty(String name, ODataComplexValue value);
 
   /**
    * Instantiates a new collection property.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java
index f8612e3..7e0c60c 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValuable.java
@@ -75,14 +75,7 @@ public interface ODataValuable {
    * 
    * @return complex value if exists; null otherwise.
    */
-  ODataComplexValue<ODataProperty> getComplexValue();
-
-  /**
-   * Gets complex value with link information (if available).
-   * 
-   * @return complex value if exists; null otherwise.
-   */
-  ODataLinkedComplexValue getLinkedComplexValue();
+  ODataComplexValue getComplexValue();
 
   /**
    * Checks if has enum value.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
index aabc836..57069e8 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
@@ -61,33 +61,18 @@ public interface ODataValue {
   <OV extends ODataValue> ODataCollectionValue<OV> asCollection();
 
   /**
-   * Check is is a complex value.
-   * 
-   * @return 'TRUE' if complex; 'FALSE' otherwise.
-   */
-  boolean isComplex();
-
-  /**
    * Casts to complex value.
    * 
-   * @param <OP> The actual ODataProperty interface.
    * @return complex value.
    */
-  <OP extends ODataProperty> ODataComplexValue<OP> asComplex();
+  ODataComplexValue asComplex();
 
   /**
    * Check is is a linked complex value.
    * 
    * @return 'TRUE' if linked complex; 'FALSE' otherwise.
    */
-  boolean isLinkedComplex();
-
-  /**
-   * Casts to complex value with link information (if available).
-   * 
-   * @return complex value with link information.
-   */
-  ODataLinkedComplexValue asLinkedComplex();
+  boolean isComplex();
 
   /**
    * Check is is an enum value.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
index 0ef933c..15a7a03 100644
--- 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
@@ -18,21 +18,20 @@
  */
 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.ComplexValue;
 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;
 
-import java.util.ArrayList;
-import java.util.List;
-
 public abstract class AbstractValuable implements Valuable, Annotatable {
 
   private ValueType valueType = null;
@@ -65,11 +64,6 @@ public abstract class AbstractValuable implements Valuable, Annotatable {
   }
 
   @Override
-  public boolean isLinkedComplex() {
-    return valueType == ValueType.LINKED_COMPLEX;
-  }
-
-  @Override
   public boolean isCollection() {
     return valueType != null && valueType != valueType.getBaseType();
   }
@@ -89,15 +83,9 @@ public abstract class AbstractValuable implements Valuable, Annotatable {
     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;
+  public ComplexValue asComplex() {
+    return isComplex() ? (ComplexValue) value : null;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
new file mode 100644
index 0000000..c50f51a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
@@ -0,0 +1,88 @@
+/*
+ * 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.Annotation;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ComplexValueImpl implements ComplexValue {
+
+  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<Link> bindingLinks = new ArrayList<Link>();
+  private final List<Annotation> annotations = new ArrayList<Annotation>();
+
+  @Override
+  public List<Property> getValue() {
+    return value;
+  }
+
+  private Link getOneByTitle(final String name, final List<Link> links) {
+    Link result = null;
+
+    for (Link link : links) {
+      if (name.equals(link.getTitle())) {
+        result = link;
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public Link getAssociationLink(final String name) {
+    return getOneByTitle(name, associationLinks);
+  }
+
+  @Override
+  public List<Link> getAssociationLinks() {
+    return associationLinks;
+  }
+
+  @Override
+  public Link getNavigationLink(final String name) {
+    return getOneByTitle(name, navigationLinks);
+  }
+
+  @Override
+  public List<Link> getNavigationLinks() {
+    return navigationLinks;
+  }
+
+  @Override
+  public List<Annotation> getAnnotations() {
+    return annotations;
+  }
+
+  @Override
+  public Link getNavigationBinding(String name) {
+    return getOneByTitle(name, bindingLinks);
+  }
+
+  @Override
+  public List<Link> getNavigationBindings() {
+    return bindingLinks;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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
deleted file mode 100644
index 778648f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkedComplexValueImpl.java
+++ /dev/null
@@ -1,88 +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.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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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<Link> bindingLinks = new ArrayList<Link>();
-  private final List<Annotation> annotations = new ArrayList<Annotation>();
-
-  @Override
-  public List<Property> getValue() {
-    return value;
-  }
-
-  private Link getOneByTitle(final String name, final List<Link> links) {
-    Link result = null;
-
-    for (Link link : links) {
-      if (name.equals(link.getTitle())) {
-        result = link;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public Link getAssociationLink(final String name) {
-    return getOneByTitle(name, associationLinks);
-  }
-
-  @Override
-  public List<Link> getAssociationLinks() {
-    return associationLinks;
-  }
-
-  @Override
-  public Link getNavigationLink(final String name) {
-    return getOneByTitle(name, navigationLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationLinks() {
-    return navigationLinks;
-  }
-
-  @Override
-  public List<Annotation> getAnnotations() {
-    return annotations;
-  }
-
-  @Override
-  public Link getNavigationBinding(String name) {
-    return getOneByTitle(name, bindingLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationBindings() {
-    return bindingLinks;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
index 140e8b8..1ca150b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
@@ -22,9 +22,7 @@ import org.apache.olingo.commons.api.domain.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValuable;
 import org.apache.olingo.commons.api.domain.ODataValue;
 
@@ -80,16 +78,11 @@ public class ODataAnnotationImpl implements ODataAnnotation {
   }
 
   @Override
-  public ODataComplexValue<ODataProperty> getComplexValue() {
+  public ODataComplexValue getComplexValue() {
     return valuable.getComplexValue();
   }
 
   @Override
-  public ODataLinkedComplexValue getLinkedComplexValue() {
-    return valuable.getLinkedComplexValue();
-  }
-
-  @Override
   public boolean hasEnumValue() {
     return valuable.hasEnumValue();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
index 90486f6..bd58713 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
@@ -18,17 +18,16 @@
  */
 package org.apache.olingo.commons.core.domain;
 
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
-import org.apache.olingo.commons.api.domain.ODataValue;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
+
 public class ODataCollectionValueImpl<OV extends ODataValue> extends AbstractODataValue
         implements ODataCollectionValue<OV>, ODataValue {
 
@@ -56,16 +55,11 @@ public class ODataCollectionValueImpl<OV extends ODataValue> extends AbstractODa
   }
 
   @Override
-  public boolean isLinkedComplex() {
+  public boolean isComplex() {
     return false;
   }
 
   @Override
-  public ODataLinkedComplexValue asLinkedComplex() {
-    return null;
-  }
-
-  @Override
   public Collection<Object> asJavaCollection() {
     final List<Object> result = new ArrayList<Object>();
     for (ODataValue value : values) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
index 553ed79..b862b71 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
@@ -18,22 +18,20 @@
  */
 package org.apache.olingo.commons.core.domain;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.olingo.commons.api.domain.AbstractODataValue;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
 import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ODataComplexValueImpl extends AbstractODataValue implements ODataComplexValue<ODataProperty>,
-        ODataLinkedComplexValue {
+public class ODataComplexValueImpl extends AbstractODataValue implements ODataComplexValue {
 
   /**
    * Navigation links (might contain in-line entities or entity sets).
@@ -61,8 +59,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
     super(typeName);
   }
 
-
-  protected ODataComplexValue<ODataProperty> getThis() {
+  protected ODataComplexValue getThis() {
     return this;
   }
 
@@ -77,16 +74,11 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
   }
 
   @Override
-  public boolean isLinkedComplex() {
+  public boolean isComplex() {
     return true;
   }
 
   @Override
-  public ODataLinkedComplexValue asLinkedComplex() {
-    return this;
-  }
-
-  @Override
   public boolean addLink(final ODataLink link) {
     boolean result = false;
 
@@ -171,15 +163,13 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
     return annotations;
   }
 
-
-
   /**
    * Adds field to the complex type.
    *
    * @param field field to be added.
    */
   @Override
-  public ODataComplexValue<ODataProperty> add(final ODataProperty field) {
+  public ODataComplexValue add(final ODataProperty field) {
     fields.put(field.getName(), field);
     return getThis();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
index bf76376..9ef7ed1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
@@ -20,7 +20,6 @@ package org.apache.olingo.commons.core.domain;
 
 import org.apache.olingo.commons.api.domain.AbstractODataValue;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 
 public class ODataEnumValueImpl extends AbstractODataValue implements ODataEnumValue {
 
@@ -47,16 +46,11 @@ public class ODataEnumValueImpl extends AbstractODataValue implements ODataEnumV
   }
 
   @Override
-  public boolean isLinkedComplex() {
+  public boolean isComplex() {
     return false;
   }
 
   @Override
-  public ODataLinkedComplexValue asLinkedComplex() {
-    return null;
-  }
-
-  @Override
   public String toString() {
     return getTypeName() + "'" + getValue() + "'";
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
index 590e292..0289309 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
@@ -18,27 +18,26 @@
  */
 package org.apache.olingo.commons.core.domain;
 
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataProperty;
+import java.net.URI;
+
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataDelta;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataSingleton;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 
-import java.net.URI;
-
 public class ODataObjectFactoryImpl implements ODataObjectFactory {
 
   protected final ODataServiceVersion version;
@@ -119,12 +118,7 @@ public class ODataObjectFactoryImpl implements ODataObjectFactory {
   }
 
   @Override
-  public ODataComplexValue<ODataProperty> newComplexValue(final String typeName) {
-    return new ODataComplexValueImpl(typeName);
-  }
-
-  @Override
-  public ODataLinkedComplexValue newLinkedComplexValue(final String typeName) {
+  public ODataComplexValue newComplexValue(final String typeName) {
     return new ODataComplexValueImpl(typeName);
   }
 
@@ -139,8 +133,7 @@ public class ODataObjectFactoryImpl implements ODataObjectFactory {
   }
 
   @Override
-  public ODataProperty newComplexProperty(final String name,
-      final ODataComplexValue<? extends ODataProperty> value) {
+  public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
 
     return new ODataPropertyImpl(name, value);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
index 4658201..c43ec59 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
@@ -18,10 +18,11 @@
  */
 package org.apache.olingo.commons.core.domain;
 
+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.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
@@ -32,8 +33,6 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 
-import java.util.UUID;
-
 public class ODataPrimitiveValueImpl extends AbstractODataValue implements ODataValue, ODataPrimitiveValue {
 
   public static class BuilderImpl implements Builder {
@@ -224,13 +223,8 @@ public class ODataPrimitiveValueImpl extends AbstractODataValue implements OData
   }
 
   @Override
-  public boolean isLinkedComplex() {
+  public boolean isComplex() {
     return false;
   }
 
-  @Override
-  public ODataLinkedComplexValue asLinkedComplex() {
-    return null;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
index bb84f7d..da1bba1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
@@ -18,22 +18,21 @@
  */
 package org.apache.olingo.commons.core.domain;
 
+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.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataAnnotatable;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValuable;
 import org.apache.olingo.commons.api.domain.ODataValue;
 
-import java.util.ArrayList;
-import java.util.List;
-
 public class ODataPropertyImpl implements ODataProperty, ODataAnnotatable, ODataValuable {
 
 
@@ -139,16 +138,11 @@ public class ODataPropertyImpl implements ODataProperty, ODataAnnotatable, OData
   }
 
   @Override
-  public ODataComplexValue<ODataProperty> getComplexValue() {
+  public ODataComplexValue getComplexValue() {
     return valuable.getComplexValue();
   }
 
   @Override
-  public ODataLinkedComplexValue getLinkedComplexValue() {
-    return valuable.getLinkedComplexValue();
-  }
-
-  @Override
   public ODataCollectionValue<ODataValue> getCollectionValue() {
     return valuable.getCollectionValue();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataValuableImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataValuableImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataValuableImpl.java
index 090a584..dbb65ee 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataValuableImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataValuableImpl.java
@@ -25,9 +25,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.olingo.commons.api.domain.ODataCollectionValue;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLinkedComplexValue;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValuable;
 import org.apache.olingo.commons.api.domain.ODataValue;
 
@@ -77,16 +75,9 @@ public class ODataValuableImpl implements ODataValuable {
   }
 
   @Override
-  public ODataComplexValue<ODataProperty> getComplexValue() {
+  public ODataComplexValue getComplexValue() {
     return hasComplexValue()
-        ? getValue().<ODataProperty> asComplex()
-        : null;
-  }
-
-  @Override
-  public ODataLinkedComplexValue getLinkedComplexValue() {
-    return hasComplexValue()
-        ? getValue().asLinkedComplex()
+        ? getValue().asComplex()
         : null;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/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 4431303..44771ca 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,11 +37,11 @@ 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.ComplexValue;
 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;
@@ -60,13 +60,13 @@ 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.ComplexValueImpl;
 import org.apache.olingo.commons.core.data.DeletedEntityImpl;
 import org.apache.olingo.commons.core.data.DeltaImpl;
 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.LinkImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
@@ -120,7 +120,6 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return value;
   }
 
-  @SuppressWarnings("unchecked")
   private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
       throws XMLStreamException, EdmPrimitiveTypeException {
 
@@ -132,8 +131,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
       if (event.isStartElement()) {
         if (value == null) {
-          value = version.compareTo(ODataServiceVersion.V40) < 0 ?
-              new ArrayList<Property>() : new LinkedComplexValueImpl();
+          value = new ComplexValueImpl();
         }
 
         if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
@@ -158,16 +156,15 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
           if (link.getRel().startsWith(
               version.getNamespace(ODataServiceVersion.NamespaceKey.NAVIGATION_LINK_REL))) {
 
-            ((LinkedComplexValue) value).getNavigationLinks().add(link);
+            ((ComplexValue) value).getNavigationLinks().add(link);
             inline(reader, event.asStartElement(), link);
           } else if (link.getRel().startsWith(
               version.getNamespace(ODataServiceVersion.NamespaceKey.ASSOCIATION_LINK_REL))) {
 
-            ((Valuable) value).asLinkedComplex().getAssociationLinks().add(link);
+            ((Valuable) value).asComplex().getAssociationLinks().add(link);
           }
         } else {
-          (value instanceof LinkedComplexValue ? ((LinkedComplexValue) value).getValue() : (List<Property>) value)
-              .add(property(reader, event.asStartElement()));
+          ((ComplexValue) value).getValue().add(property(reader, event.asStartElement()));
         }
       }
 
@@ -200,8 +197,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
         switch (guessPropertyType(reader, typeInfo)) {
         case COMPLEX:
           final Object complexValue = fromComplexOrEnum(reader, event.asStartElement());
-          valueType = complexValue instanceof LinkedComplexValue ?
-              ValueType.COLLECTION_LINKED_COMPLEX : ValueType.COLLECTION_COMPLEX;
+          valueType = ValueType.COLLECTION_COMPLEX;
           values.add(complexValue);
           break;
 
@@ -313,8 +309,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
       case COMPLEX:
         final Object complexValue = fromComplexOrEnum(reader, start);
-        valuable.setValue(complexValue instanceof LinkedComplexValue ? ValueType.LINKED_COMPLEX :
-            complexValue instanceof List<?> ? ValueType.COMPLEX : ValueType.ENUM,
+        valuable.setValue(complexValue instanceof ComplexValue ? ValueType.COMPLEX : ValueType.ENUM,
             complexValue);
         break;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/0d57a076/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
index 68b116a..7d07f5e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -18,16 +18,24 @@
  */
 package org.apache.olingo.commons.core.serialization;
 
-import com.fasterxml.aalto.stax.OutputFactoryImpl;
+import java.io.Writer;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 
 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.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
-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.ValueType;
@@ -47,15 +55,7 @@ import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 
-import javax.xml.XMLConstants;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import java.io.Writer;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
 
 public class AtomSerializer extends AbstractAtomDealer implements ODataSerializer {
 
@@ -89,7 +89,6 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     }
   }
 
-  @SuppressWarnings("unchecked")
   private void value(final XMLStreamWriter writer,
       final ValueType valueType, final EdmPrimitiveTypeKind kind, final Object value)
       throws XMLStreamException, EdmPrimitiveTypeException {
@@ -114,16 +113,10 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     case COLLECTION_GEOSPATIAL:
     case COLLECTION_ENUM:
     case COLLECTION_COMPLEX:
-    case COLLECTION_LINKED_COMPLEX:
       collection(writer, valueType.getBaseType(), kind, (List<?>) value);
       break;
-    case LINKED_COMPLEX:
-      for (Property property : ((LinkedComplexValue) value).getValue()) {
-        property(writer, property, false);
-      }
-      break;
     case COMPLEX:
-      for (Property property : (List<Property>) value) {
+      for (Property property : ((ComplexValue) value).getValue()) {
         property(writer, property, false);
       }
       break;
@@ -154,9 +147,9 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
 
     value(writer, property.getValueType(), typeInfo == null ? null : typeInfo.getPrimitiveTypeKind(),
         property.getValue());
-    if (!property.isNull() && property.isLinkedComplex()) {
-      links(writer, property.asLinkedComplex().getAssociationLinks());
-      links(writer, property.asLinkedComplex().getNavigationLinks());
+    if (!property.isNull() && property.isComplex()) {
+      links(writer, property.asComplex().getAssociationLinks());
+      links(writer, property.asComplex().getNavigationLinks());
     }
 
     writer.writeEndElement();
@@ -529,15 +522,15 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
 
   private void reference(final Writer outWriter, final ResWrap<URI> container) throws XMLStreamException {
     final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
-    
+
     writer.writeStartDocument();
-    
+
     writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF);
     writer.writeNamespace(Constants.ATTR_METADATA, version.getNamespace(NamespaceKey.METADATA));
     writer.writeAttribute(Constants.ATTR_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString());
     writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString());
     writer.writeEndElement();
-    
+
     writer.writeEndDocument();
   }
 
@@ -555,8 +548,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
         property(writer, (Property) obj);
       } else if (obj instanceof Link) {
         link(writer, (Link) obj);
-      } else if(obj instanceof URI) {
-        reference(writer,(ResWrap<URI>) container);
+      } else if (obj instanceof URI) {
+        reference(writer, (ResWrap<URI>) container);
       }
     } catch (final XMLStreamException e) {
       throw new ODataSerializerException(e);