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:37 UTC
[2/3] olingo-odata4 git commit: [OLINGO-575] Start merging
ComplexValue and LinkedComplexValue
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);