http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 25b405a..f38d795 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 @@ -48,25 +48,25 @@ 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.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.ODataDeletedEntity.Reason; -import org.apache.olingo.commons.api.domain.ODataDelta; -import org.apache.olingo.commons.api.domain.ODataDeltaLink; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -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.ODataLinked; -import org.apache.olingo.commons.api.domain.ODataOperation; -import org.apache.olingo.commons.api.domain.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataServiceDocument; -import org.apache.olingo.commons.api.domain.ODataValuable; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientAnnotatable; +import org.apache.olingo.commons.api.domain.ClientAnnotation; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientDeletedEntity.Reason; +import org.apache.olingo.commons.api.domain.ClientDelta; +import org.apache.olingo.commons.api.domain.ClientDeltaLink; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientInlineEntity; +import org.apache.olingo.commons.api.domain.ClientInlineEntitySet; +import org.apache.olingo.commons.api.domain.ClientLink; +import org.apache.olingo.commons.api.domain.ClientLinkType; +import org.apache.olingo.commons.api.domain.ClientLinked; +import org.apache.olingo.commons.api.domain.ClientOperation; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientServiceDocument; +import org.apache.olingo.commons.api.domain.ClientValuable; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmComplexType; @@ -87,10 +87,10 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; 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.domain.ODataAnnotationImpl; -import org.apache.olingo.commons.core.domain.ODataDeletedEntityImpl; -import org.apache.olingo.commons.core.domain.ODataDeltaLinkImpl; -import org.apache.olingo.commons.core.domain.ODataPropertyImpl; +import org.apache.olingo.commons.core.domain.ClientAnnotationImpl; +import org.apache.olingo.commons.core.domain.ClientDeletedEntityImpl; +import org.apache.olingo.commons.core.domain.ClientDeltaLinkImpl; +import org.apache.olingo.commons.core.domain.ClientPropertyImpl; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.commons.core.serialization.ContextURLParser; @@ -111,17 +111,17 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public boolean add(final ODataEntity entity, final ODataProperty property) { + public boolean add(final ClientEntity entity, final ClientProperty property) { return entity.getProperties().add(property); } - protected boolean add(final ODataEntitySet entitySet, final ODataEntity entity) { + protected boolean add(final ClientEntitySet entitySet, final ClientEntity entity) { return entitySet.getEntities().add(entity); } @Override - public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) { - final ODataServiceDocument serviceDocument = new ODataServiceDocument(); + public ClientServiceDocument getODataServiceDocument(final ServiceDocument resource) { + final ClientServiceDocument serviceDocument = new ClientServiceDocument(); for (ServiceDocumentItem entitySet : resource.getEntitySets()) { serviceDocument.getEntitySets(). @@ -146,7 +146,7 @@ public class ODataBinderImpl implements ODataBinder { return serviceDocument; } - private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable) { + private void updateValuable(final Valuable propertyResource, final ClientValuable odataValuable) { final Object propertyValue = getValue(odataValuable.getValue()); if (odataValuable.hasPrimitiveValue()) { propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName()); @@ -160,10 +160,10 @@ public class ODataBinderImpl implements ODataBinder { propertyResource.setType(odataValuable.getComplexValue().getTypeName()); propertyResource.setValue(ValueType.COMPLEX, propertyValue); } else if (odataValuable.hasCollectionValue()) { - final ODataCollectionValue<ODataValue> collectionValue = + final ClientCollectionValue<ClientValue> collectionValue = odataValuable.getCollectionValue(); propertyResource.setType(collectionValue.getTypeName()); - final ODataValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null; + final ClientValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null; ValueType valueType = ValueType.COLLECTION_PRIMITIVE; if (value == null) { valueType = ValueType.COLLECTION_PRIMITIVE; @@ -179,8 +179,8 @@ public class ODataBinderImpl implements ODataBinder { } } - private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) { - for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { + private void annotations(final ClientAnnotatable odataAnnotatable, final Annotatable annotatable) { + for (ClientAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { final Annotation annotation = new Annotation(); annotation.setTerm(odataAnnotation.getTerm()); @@ -192,7 +192,7 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public EntityCollection getEntitySet(final ODataEntitySet odataEntitySet) { + public EntityCollection getEntitySet(final ClientEntitySet odataEntitySet) { final EntityCollection entitySet = new EntityCollection(); entitySet.setCount(odataEntitySet.getCount()); @@ -202,7 +202,7 @@ public class ODataBinderImpl implements ODataBinder { entitySet.setNext(next); } - for (ODataEntity entity : odataEntitySet.getEntities()) { + for (ClientEntity entity : odataEntitySet.getEntities()) { entitySet.getEntities().add(getEntity(entity)); } @@ -211,12 +211,12 @@ public class ODataBinderImpl implements ODataBinder { return entitySet; } - protected void links(final ODataLinked odataLinked, final Linked linked) { + protected void links(final ClientLinked odataLinked, final Linked linked) { // ------------------------------------------------------------- // Append navigation links (handling inline entity / entity set as well) // ------------------------------------------------------------- // handle navigation links - for (ODataLink link : odataLinked.getNavigationLinks()) { + for (ClientLink link : odataLinked.getNavigationLinks()) { // append link LOG.debug("Append navigation link\n{}", link); linked.getNavigationLinks().add(getLink(link)); @@ -226,22 +226,22 @@ public class ODataBinderImpl implements ODataBinder { // ------------------------------------------------------------- // Append association links // ------------------------------------------------------------- - for (ODataLink link : odataLinked.getAssociationLinks()) { + for (ClientLink link : odataLinked.getAssociationLinks()) { LOG.debug("Append association link\n{}", link); linked.getAssociationLinks().add(getLink(link)); } // ------------------------------------------------------------- for (Link link : linked.getNavigationLinks()) { - final ODataLink odataLink = odataLinked.getNavigationLink(link.getTitle()); - if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof ODataInlineEntitySet)) { + final ClientLink odataLink = odataLinked.getNavigationLink(link.getTitle()); + if (!(odataLink instanceof ClientInlineEntity) && !(odataLink instanceof ClientInlineEntitySet)) { annotations(odataLink, link); } } } @Override - public Entity getEntity(final ODataEntity odataEntity) { + public Entity getEntity(final ClientEntity odataEntity) { final Entity entity = new Entity(); entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString()); @@ -272,7 +272,7 @@ public class ODataBinderImpl implements ODataBinder { // ------------------------------------------------------------- // Append edit-media links // ------------------------------------------------------------- - for (ODataLink link : odataEntity.getMediaEditLinks()) { + for (ClientLink link : odataEntity.getMediaEditLinks()) { LOG.debug("Append edit-media link\n{}", link); entity.getMediaEditLinks().add(getLink(link)); } @@ -284,7 +284,7 @@ public class ODataBinderImpl implements ODataBinder { entity.setMediaETag(odataEntity.getMediaETag()); } - for (ODataProperty property : odataEntity.getProperties()) { + for (ClientProperty property : odataEntity.getProperties()) { entity.getProperties().add(getProperty(property)); } @@ -294,7 +294,7 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public Link getLink(final ODataLink link) { + public Link getLink(final ClientLink link) { final Link linkResource = new Link(); linkResource.setRel(link.getRel()); linkResource.setTitle(link.getName()); @@ -302,15 +302,15 @@ public class ODataBinderImpl implements ODataBinder { linkResource.setType(link.getType().toString()); linkResource.setMediaETag(link.getMediaETag()); - if (link instanceof ODataInlineEntity) { + if (link instanceof ClientInlineEntity) { // append inline entity - final ODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity(); + final ClientEntity inlineEntity = ((ClientInlineEntity) link).getEntity(); LOG.debug("Append in-line entity\n{}", inlineEntity); linkResource.setInlineEntity(getEntity(inlineEntity)); - } else if (link instanceof ODataInlineEntitySet) { + } else if (link instanceof ClientInlineEntitySet) { // append inline entity set - final ODataEntitySet InlineEntitySet = ((ODataInlineEntitySet) link).getEntitySet(); + final ClientEntitySet InlineEntitySet = ((ClientInlineEntitySet) link).getEntitySet(); LOG.debug("Append in-line entity set\n{}", InlineEntitySet); linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet)); @@ -320,7 +320,7 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public Property getProperty(final ODataProperty property) { + public Property getProperty(final ClientProperty property) { final Property propertyResource = new Property(); propertyResource.setName(property.getName()); @@ -330,7 +330,7 @@ public class ODataBinderImpl implements ODataBinder { return propertyResource; } - protected Object getValue(final ODataValue value) { + protected Object getValue(final ClientValue value) { Object valueResource = null; if (value == null) { return null; @@ -341,7 +341,7 @@ public class ODataBinderImpl implements ODataBinder { valueResource = value.asPrimitive().toValue(); } else if (value.isComplex()) { List<Property> complexProperties = new ArrayList<Property>(); - for (final ODataProperty propertyValue : value.asComplex()) { + for (final ClientProperty propertyValue : value.asComplex()) { complexProperties.add(getProperty(propertyValue)); } final ComplexValue lcValueResource = new ComplexValue(); @@ -351,10 +351,10 @@ public class ODataBinderImpl implements ODataBinder { valueResource = lcValueResource; } else if (value.isCollection()) { - final ODataCollectionValue<? extends ODataValue> _value = value.asCollection(); + final ClientCollectionValue<? extends ClientValue> _value = value.asCollection(); ArrayList<Object> lcValueResource = new ArrayList<Object>(); - for (final ODataValue collectionValue : _value) { + for (final ClientValue collectionValue : _value) { lcValueResource.add(getValue(collectionValue)); } valueResource = lcValueResource; @@ -362,7 +362,7 @@ public class ODataBinderImpl implements ODataBinder { return valueResource; } - private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatable odataAnnotatable) { + private void odataAnnotations(final Annotatable annotatable, final ClientAnnotatable odataAnnotatable) { for (Annotation annotation : annotatable.getAnnotations()) { FullQualifiedName fqn = null; if (client instanceof EdmEnabledODataClient) { @@ -380,14 +380,14 @@ public class ODataBinderImpl implements ODataBinder { } } - final ODataAnnotation odataAnnotation = - new ODataAnnotationImpl(annotation.getTerm(), getODataValue(fqn, annotation, null, null)); + final ClientAnnotation odataAnnotation = + new ClientAnnotationImpl(annotation.getTerm(), getODataValue(fqn, annotation, null, null)); odataAnnotatable.getAnnotations().add(odataAnnotation); } } @Override - public ODataEntitySet getODataEntitySet(final ResWrap<EntityCollection> resource) { + public ClientEntitySet getODataEntitySet(final ResWrap<EntityCollection> resource) { if (LOG.isDebugEnabled()) { final StringWriter writer = new StringWriter(); try { @@ -405,7 +405,7 @@ public class ODataBinderImpl implements ODataBinder { final URI next = resource.getPayload().getNext(); - final ODataEntitySet entitySet = next == null + final ClientEntitySet entitySet = next == null ? client.getObjectFactory().newEntitySet() : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString())); @@ -427,29 +427,29 @@ public class ODataBinderImpl implements ODataBinder { } protected void odataNavigationLinks(final EdmType edmType, - final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) { + final Linked linked, final ClientLinked odataLinked, final String metadataETag, final URI base) { for (Link link : linked.getNavigationLinks()) { final String href = link.getHref(); final String title = link.getTitle(); final Entity inlineEntity = link.getInlineEntity(); final EntityCollection inlineEntitySet = link.getInlineEntitySet(); if (inlineEntity == null && inlineEntitySet == null) { - ODataLinkType linkType = null; + ClientLinkType linkType = null; if (edmType instanceof EdmStructuredType) { final EdmNavigationProperty navProp = ((EdmStructuredType) edmType).getNavigationProperty(title); if (navProp != null) { linkType = navProp.isCollection() ? - ODataLinkType.ENTITY_SET_NAVIGATION : - ODataLinkType.ENTITY_NAVIGATION; + ClientLinkType.ENTITY_SET_NAVIGATION : + ClientLinkType.ENTITY_NAVIGATION; } } if (linkType == null) { linkType = link.getType() == null ? - ODataLinkType.ENTITY_NAVIGATION : - ODataLinkType.fromString(link.getRel(), link.getType()); + ClientLinkType.ENTITY_NAVIGATION : + ClientLinkType.fromString(link.getRel(), link.getType()); } - odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION ? + odataLinked.addLink(linkType == ClientLinkType.ENTITY_NAVIGATION ? client.getObjectFactory().newEntityNavigationLink(title, URIUtils.getURI(base, href)) : client.getObjectFactory().newEntitySetNavigationLink(title, URIUtils.getURI(base, href))); } else if (inlineEntity != null) { @@ -461,24 +461,24 @@ public class ODataBinderImpl implements ODataBinder { } } - for (ODataLink link : odataLinked.getNavigationLinks()) { - if (!(link instanceof ODataInlineEntity) && !(link instanceof ODataInlineEntitySet)) { + for (ClientLink link : odataLinked.getNavigationLinks()) { + if (!(link instanceof ClientInlineEntity) && !(link instanceof ClientInlineEntitySet)) { odataAnnotations(linked.getNavigationLink(link.getName()), link); } } } - private ODataInlineEntity createODataInlineEntity(final Entity inlineEntity, + private ClientInlineEntity createODataInlineEntity(final Entity inlineEntity, final URI uri, final String title, final String metadataETag) { - return new ODataInlineEntity(uri, ODataLinkType.ENTITY_NAVIGATION, title, + return new ClientInlineEntity(uri, ClientLinkType.ENTITY_NAVIGATION, title, getODataEntity(new ResWrap<Entity>( inlineEntity.getBaseURI() == null ? null : inlineEntity.getBaseURI(), metadataETag, inlineEntity))); } - private ODataInlineEntitySet createODataInlineEntitySet(final EntityCollection inlineEntitySet, + private ClientInlineEntitySet createODataInlineEntitySet(final EntityCollection inlineEntitySet, final URI uri, final String title, final String metadataETag) { - return new ODataInlineEntitySet(uri, ODataLinkType.ENTITY_SET_NAVIGATION, title, + return new ClientInlineEntitySet(uri, ClientLinkType.ENTITY_SET_NAVIGATION, title, getODataEntitySet(new ResWrap<EntityCollection>( inlineEntitySet.getBaseURI() == null ? null : inlineEntitySet.getBaseURI(), metadataETag, inlineEntitySet))); @@ -565,7 +565,7 @@ public class ODataBinderImpl implements ODataBinder { return type; } - private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) { + private ClientLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) { if (property.isCollection()) { EntityCollection inlineEntitySet = new EntityCollection(); for (final Object inlined : property.asCollection()) { @@ -584,7 +584,7 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public ODataEntity getODataEntity(final ResWrap<Entity> resource) { + public ClientEntity getODataEntity(final ResWrap<Entity> resource) { if (LOG.isDebugEnabled()) { final StringWriter writer = new StringWriter(); try { @@ -610,7 +610,7 @@ public class ODataBinderImpl implements ODataBinder { typeName = new FullQualifiedName(resource.getPayload().getType()); } - final ODataEntity entity = resource.getPayload().getSelfLink() == null + final ClientEntity entity = resource.getPayload().getSelfLink() == null ? client.getObjectFactory().newEntity(typeName) : client.getObjectFactory().newEntity(typeName, URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref())); @@ -635,7 +635,7 @@ public class ODataBinderImpl implements ODataBinder { newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))); } - for (ODataOperation operation : resource.getPayload().getOperations()) { + for (ClientOperation operation : resource.getPayload().getOperations()) { operation.setTarget(URIUtils.getURI(base, operation.getTarget())); entity.getOperations().add(operation); } @@ -670,12 +670,12 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public ODataProperty getODataProperty(final ResWrap<Property> resource) { + public ClientProperty getODataProperty(final ResWrap<Property> resource) { final Property payload = resource.getPayload(); final EdmTypeInfo typeInfo = buildTypeInfo(ContextURLParser.parse(resource.getContextURL()), resource.getMetadataETag(), payload.getName(), payload.getType()); - final ODataProperty property = new ODataPropertyImpl(payload.getName(), + final ClientProperty property = new ClientPropertyImpl(payload.getName(), getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(), payload, resource.getContextURL(), resource.getMetadataETag())); odataAnnotations(payload, property); @@ -717,10 +717,10 @@ public class ODataBinderImpl implements ODataBinder { return typeInfo; } - protected ODataProperty getODataProperty(final EdmType type, final Property resource) { + protected ClientProperty getODataProperty(final EdmType type, final Property resource) { final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : type.getFullQualifiedName(), resource.getType()); - final ODataProperty property = new ODataPropertyImpl(resource.getName(), + final ClientProperty property = new ClientPropertyImpl(resource.getName(), getODataValue(typeInfo == null ? null : typeInfo.getFullQualifiedName(), resource, null, null)); odataAnnotations(resource, property); @@ -728,7 +728,7 @@ public class ODataBinderImpl implements ODataBinder { return property; } - protected ODataValue getODataValue(final FullQualifiedName type, + protected ClientValue getODataValue(final FullQualifiedName type, final Valuable valuable, final URI contextURL, final String metadataETag) { // fixes enum values treated as primitive when no type information is available @@ -739,7 +739,7 @@ public class ODataBinderImpl implements ODataBinder { } } - ODataValue value = null; + ClientValue value = null; if (valuable.isCollection()) { value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")"); @@ -753,7 +753,7 @@ public class ODataBinderImpl implements ODataBinder { value = client.getObjectFactory().newEnumValue(type == null ? null : type.toString(), valuable.asEnum().toString()); } else if (valuable.isComplex()) { - final ODataComplexValue lcValue = + final ClientComplexValue lcValue = client.getObjectFactory().newComplexValue(type == null ? null : type.toString()); EdmComplexType edmType = null; @@ -813,7 +813,7 @@ public class ODataBinderImpl implements ODataBinder { : EdmPrimitiveTypeKind.valueOfFQN(type.toString())). build(); } else if (valuable.isComplex()) { - final ODataComplexValue cValue = + final ClientComplexValue cValue = client.getObjectFactory().newComplexValue(type == null ? null : type.toString()); if (!valuable.isNull()) { @@ -843,14 +843,14 @@ public class ODataBinderImpl implements ODataBinder { } @Override - public ODataDelta getODataDelta(final ResWrap<Delta> resource) { + public ClientDelta getODataDelta(final ResWrap<Delta> resource) { final URI base = resource.getContextURL() == null ? resource.getPayload().getBaseURI() : ContextURLParser.parse(resource.getContextURL()).getServiceRoot(); final URI next = resource.getPayload().getNext(); - final ODataDelta delta = next == null + final ClientDelta delta = next == null ? client.getObjectFactory().newDelta() : client.getObjectFactory().newDelta(URIUtils.getURI(base, next.toASCIIString())); @@ -867,7 +867,7 @@ public class ODataBinderImpl implements ODataBinder { new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource))); } for (DeletedEntity deletedEntity : resource.getPayload().getDeletedEntities()) { - final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl(); + final ClientDeletedEntityImpl impl = new ClientDeletedEntityImpl(); impl.setId(URIUtils.getURI(base, deletedEntity.getId())); impl.setReason(Reason.valueOf(deletedEntity.getReason().name())); @@ -877,7 +877,7 @@ public class ODataBinderImpl implements ODataBinder { odataAnnotations(resource.getPayload(), delta); for (DeltaLink link : resource.getPayload().getAddedLinks()) { - final ODataDeltaLink impl = new ODataDeltaLinkImpl(); + final ClientDeltaLink impl = new ClientDeltaLinkImpl(); impl.setRelationship(link.getRelationship()); impl.setSource(URIUtils.getURI(base, link.getSource())); impl.setTarget(URIUtils.getURI(base, link.getTarget())); @@ -887,7 +887,7 @@ public class ODataBinderImpl implements ODataBinder { delta.getAddedLinks().add(impl); } for (DeltaLink link : resource.getPayload().getDeletedLinks()) { - final ODataDeltaLink impl = new ODataDeltaLinkImpl(); + final ClientDeltaLink impl = new ClientDeltaLinkImpl(); impl.setRelationship(link.getRelationship()); impl.setSource(URIUtils.getURI(base, link.getSource())); impl.setTarget(URIUtils.getURI(base, link.getTarget()));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java index c0af3af..80972be 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java @@ -33,12 +33,12 @@ import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ResWrap; -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.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataServiceDocument; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientError; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientServiceDocument; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.provider.CsdlSchema; @@ -73,14 +73,14 @@ public class ODataReaderImpl implements ODataReader { } @Override - public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) + public ClientServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) throws ODataDeserializerException { return client.getBinder().getODataServiceDocument( client.getDeserializer(format).toServiceDocument(input).getPayload()); } @Override - public ODataError readError(final InputStream inputStream, final ODataFormat format) + public ClientError readError(final InputStream inputStream, final ODataFormat format) throws ODataDeserializerException { return client.getDeserializer(format).toError(inputStream); } @@ -95,28 +95,28 @@ public class ODataReaderImpl implements ODataReader { res = new ResWrap<T>( (URI) null, null, - reference.cast(new ODataEntitySetIterator<ODataEntitySet, ODataEntity>( + reference.cast(new ODataEntitySetIterator<ClientEntitySet, ClientEntity>( client, src, ODataFormat.fromString(format)))); - } else if (ODataEntitySet.class.isAssignableFrom(reference)) { + } else if (ClientEntitySet.class.isAssignableFrom(reference)) { final ResWrap<EntityCollection> resource = client.getDeserializer(ODataFormat.fromString(format)) .toEntitySet(src); res = new ResWrap<T>( resource.getContextURL(), resource.getMetadataETag(), reference.cast(client.getBinder().getODataEntitySet(resource))); - } else if (ODataEntity.class.isAssignableFrom(reference)) { + } else if (ClientEntity.class.isAssignableFrom(reference)) { final ResWrap<Entity> container = client.getDeserializer(ODataFormat.fromString(format)).toEntity(src); res = new ResWrap<T>( container.getContextURL(), container.getMetadataETag(), reference.cast(client.getBinder().getODataEntity(container))); - } else if (ODataProperty.class.isAssignableFrom(reference)) { + } else if (ClientProperty.class.isAssignableFrom(reference)) { final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src); res = new ResWrap<T>( container.getContextURL(), container.getMetadataETag(), reference.cast(client.getBinder().getODataProperty(container))); - } else if (ODataValue.class.isAssignableFrom(reference)) { + } else if (ClientValue.class.isAssignableFrom(reference)) { res = new ResWrap<T>( (URI) null, null, @@ -130,14 +130,14 @@ public class ODataReaderImpl implements ODataReader { (URI) null, null, reference.cast(readMetadata(src))); - } else if (ODataServiceDocument.class.isAssignableFrom(reference)) { + } else if (ClientServiceDocument.class.isAssignableFrom(reference)) { final ResWrap<ServiceDocument> resource = client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src); res = new ResWrap<T>( resource.getContextURL(), resource.getMetadataETag(), reference.cast(client.getBinder().getODataServiceDocument(resource.getPayload()))); - } else if (ODataError.class.isAssignableFrom(reference)) { + } else if (ClientError.class.isAssignableFrom(reference)) { res = new ResWrap<T>( (URI) null, null, @@ -158,19 +158,19 @@ public class ODataReaderImpl implements ODataReader { } @Override - public ODataEntitySet readEntitySet(final InputStream input, final ODataFormat format) + public ClientEntitySet readEntitySet(final InputStream input, final ODataFormat format) throws ODataDeserializerException { return client.getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input)); } @Override - public ODataEntity readEntity(final InputStream input, final ODataFormat format) + public ClientEntity readEntity(final InputStream input, final ODataFormat format) throws ODataDeserializerException { return client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input)); } @Override - public ODataProperty readProperty(final InputStream input, final ODataFormat format) + public ClientProperty readProperty(final InputStream input, final ODataFormat format) throws ODataDeserializerException { return client.getBinder().getODataProperty(client.getDeserializer(format).toProperty(input)); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java index b28b692..8191886 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java @@ -32,9 +32,9 @@ import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.serialization.ODataWriter; import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataLink; -import org.apache.olingo.commons.api.domain.ODataProperty; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientLink; +import org.apache.olingo.commons.api.domain.ClientProperty; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataSerializerException; @@ -47,7 +47,7 @@ public class ODataWriterImpl implements ODataWriter { } @Override - public InputStream writeEntities(final Collection<ODataEntity> entities, final ODataFormat format) + public InputStream writeEntities(final Collection<ClientEntity> entities, final ODataFormat format) throws ODataSerializerException { ByteArrayOutputStream output = new ByteArrayOutputStream(); OutputStreamWriter writer; @@ -57,7 +57,7 @@ public class ODataWriterImpl implements ODataWriter { writer = null; } try { - for (ODataEntity entity : entities) { + for (ClientEntity entity : entities) { client.getSerializer(format).write(writer, client.getBinder().getEntity(entity)); } @@ -68,13 +68,13 @@ public class ODataWriterImpl implements ODataWriter { } @Override - public InputStream writeEntity(final ODataEntity entity, final ODataFormat format) + public InputStream writeEntity(final ClientEntity entity, final ODataFormat format) throws ODataSerializerException { - return writeEntities(Collections.<ODataEntity>singleton(entity), format); + return writeEntities(Collections.<ClientEntity>singleton(entity), format); } @Override - public InputStream writeProperty(final ODataProperty property, final ODataFormat format) + public InputStream writeProperty(final ClientProperty property, final ODataFormat format) throws ODataSerializerException { final ByteArrayOutputStream output = new ByteArrayOutputStream(); OutputStreamWriter writer; @@ -93,7 +93,7 @@ public class ODataWriterImpl implements ODataWriter { } @Override - public InputStream writeLink(final ODataLink link, final ODataFormat format) throws ODataSerializerException { + public InputStream writeLink(final ClientLink link, final ODataFormat format) throws ODataSerializerException { final ByteArrayOutputStream output = new ByteArrayOutputStream(); OutputStreamWriter writer; try { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java index 608dc3a..e1ac9c1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java @@ -50,7 +50,7 @@ import org.apache.olingo.client.api.http.WrappingHttpClientFactory; import org.apache.olingo.client.api.uri.SegmentType; import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory; import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary; @@ -331,7 +331,7 @@ public final class URIUtils { return res; } - public static URI buildFunctionInvokeURI(final URI uri, final Map<String, ODataValue> parameters) { + public static URI buildFunctionInvokeURI(final URI uri, final Map<String, ClientValue> parameters) { final String rawQuery = uri.getRawQuery(); String baseURI = StringUtils.substringBefore(uri.toASCIIString(), "?" + rawQuery); if (baseURI.endsWith("()")) { @@ -339,7 +339,7 @@ public final class URIUtils { } final StringBuilder inlineParams = new StringBuilder(); - for (Map.Entry<String, ODataValue> param : parameters.entrySet()) { + for (Map.Entry<String, ClientValue> param : parameters.entrySet()) { inlineParams.append(param.getKey()).append("="); Object value = null; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java index 5d5671a..873b946 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java @@ -22,8 +22,8 @@ import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.core.AbstractTest; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; import org.junit.Test; @@ -45,14 +45,14 @@ public class EntitySetTest extends AbstractTest { private void read(final ODataFormat format) throws IOException, ODataDeserializerException { final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format)); - final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet( + final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet( getClient().getDeserializer(format).toEntitySet(input)); assertNotNull(entitySet); assertEquals(2, entitySet.getEntities().size()); assertNull(entitySet.getNext()); - final ODataEntitySet written = + final ClientEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null, getClient().getBinder().getEntitySet(entitySet))); assertEquals(entitySet, written); @@ -70,16 +70,16 @@ public class EntitySetTest extends AbstractTest { private void ref(final ODataFormat format) throws ODataDeserializerException { final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format)); - final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet( + final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet( getClient().getDeserializer(format).toEntitySet(input)); assertNotNull(entitySet); - for (ODataEntity entity : entitySet.getEntities()) { + for (ClientEntity entity : entitySet.getEntities()) { assertNotNull(entity.getId()); } entitySet.setCount(entitySet.getEntities().size()); - final ODataEntitySet written = + final ClientEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null, getClient().getBinder().getEntitySet(entitySet))); assertEquals(entitySet, written); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 9935870..de35c02 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 @@ -33,15 +33,15 @@ import org.apache.olingo.client.core.AbstractTest; 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.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataValuable; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientAnnotation; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientInlineEntitySet; +import org.apache.olingo.commons.api.domain.ClientLink; +import org.apache.olingo.commons.api.domain.ClientLinkType; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientValuable; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.format.ODataFormat; @@ -80,35 +80,35 @@ public class EntityTest extends AbstractTest { private void singleton(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString()); - final ODataProperty birthday = entity.getProperty("Birthday"); + final ClientProperty birthday = entity.getProperty("Birthday"); assertTrue(birthday.hasPrimitiveValue()); assertEquals(EdmDateTimeOffset.getInstance(), birthday.getPrimitiveValue().getType()); - final ODataProperty timeBetweenLastTwoOrders = entity.getProperty("TimeBetweenLastTwoOrders"); + final ClientProperty timeBetweenLastTwoOrders = entity.getProperty("TimeBetweenLastTwoOrders"); assertTrue(timeBetweenLastTwoOrders.hasPrimitiveValue()); assertEquals(EdmDuration.getInstance(), timeBetweenLastTwoOrders.getPrimitiveValue().getType()); int checked = 0; - for (ODataLink link : entity.getNavigationLinks()) { + for (ClientLink link : entity.getNavigationLinks()) { if ("Parent".equals(link.getName())) { checked++; - assertEquals(ODataLinkType.ENTITY_NAVIGATION, link.getType()); + assertEquals(ClientLinkType.ENTITY_NAVIGATION, link.getType()); } if ("Orders".equals(link.getName())) { checked++; if (format == ODataFormat.ATOM) { - assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, link.getType()); + assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType()); } } if ("Company".equals(link.getName())) { checked++; - assertEquals(ODataLinkType.ENTITY_NAVIGATION, link.getType()); + assertEquals(ClientLinkType.ENTITY_NAVIGATION, link.getType()); } } assertEquals(3, checked); @@ -121,7 +121,7 @@ public class EntityTest extends AbstractTest { // operations won't get serialized entity.getOperations().clear(); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -139,25 +139,25 @@ public class EntityTest extends AbstractTest { private void withEnums(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); - final ODataProperty skinColor = entity.getProperty("SkinColor"); + final ClientProperty skinColor = entity.getProperty("SkinColor"); assertTrue(skinColor.hasEnumValue()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", skinColor.getEnumValue().getTypeName()); assertEquals("Red", skinColor.getEnumValue().getValue()); - final ODataProperty coverColors = entity.getProperty("CoverColors"); + final ClientProperty coverColors = entity.getProperty("CoverColors"); assertTrue(coverColors.hasCollectionValue()); - for (final Iterator<ODataValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) { - final ODataValue item = itor.next(); + for (final Iterator<ClientValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) { + final ClientValue item = itor.next(); assertTrue(item.isEnum()); } // operations won't get serialized entity.getOperations().clear(); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -176,15 +176,15 @@ public class EntityTest extends AbstractTest { private void withInlineEntitySet(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream( "Accounts_101_expand_MyPaymentInstruments." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); - final ODataLink instruments = entity.getNavigationLink("MyPaymentInstruments"); + final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments"); assertNotNull(instruments); - assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, instruments.getType()); + assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, instruments.getType()); - final ODataInlineEntitySet inline = instruments.asInlineEntitySet(); + final ClientInlineEntitySet inline = instruments.asInlineEntitySet(); assertNotNull(inline); assertEquals(3, inline.getEntitySet().getEntities().size()); @@ -192,7 +192,7 @@ public class EntityTest extends AbstractTest { inline.getEntitySet().setCount(3); // operations won't get serialized entity.getOperations().clear(); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -211,7 +211,7 @@ public class EntityTest extends AbstractTest { private void mediaEntity(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream( "Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); @@ -219,7 +219,7 @@ public class EntityTest extends AbstractTest { assertNotNull(entity.getMediaContentSource()); assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag()); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -237,16 +237,16 @@ public class EntityTest extends AbstractTest { private void withStream(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); assertFalse(entity.isMediaEntity()); - final ODataLink editMedia = entity.getMediaEditLink("Photo"); + final ClientLink editMedia = entity.getMediaEditLink("Photo"); assertNotNull(editMedia); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -264,13 +264,13 @@ public class EntityTest extends AbstractTest { private void ref(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); assertNotNull(entity.getId()); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -288,17 +288,17 @@ public class EntityTest extends AbstractTest { private void complexNavigationProperties(final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); - final ODataComplexValue addressValue = entity.getProperty("Address").getComplexValue(); + final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue(); assertNotNull(addressValue); assertNotNull(addressValue.getNavigationLink("Country")); // ETag is not serialized entity.setETag(null); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -316,13 +316,13 @@ public class EntityTest extends AbstractTest { private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, Exception { final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format)); - final ODataEntity entity = getClient().getBinder().getODataEntity( + final ClientEntity entity = getClient().getBinder().getODataEntity( getClient().getDeserializer(format).toEntity(input)); assertNotNull(entity); assertFalse(entity.getAnnotations().isEmpty()); - ODataAnnotation annotation = entity.getAnnotations().get(0); + ClientAnnotation annotation = entity.getAnnotations().get(0); assertEquals("com.contoso.display.highlight", annotation.getTerm()); assertEquals(true, annotation.getPrimitiveValue().toCastValue(Boolean.class)); @@ -334,7 +334,7 @@ public class EntityTest extends AbstractTest { assertEquals("com.contoso.display.style", annotation.getTerm()); assertTrue(annotation.hasComplexValue()); - final ODataLink orders = entity.getNavigationLink("Orders"); + final ClientLink orders = entity.getNavigationLink("Orders"); assertFalse(orders.getAnnotations().isEmpty()); annotation = orders.getAnnotations().get(0); @@ -344,7 +344,7 @@ public class EntityTest extends AbstractTest { assertEquals(2, annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0); - final ODataEntity written = getClient().getBinder().getODataEntity( + final ClientEntity written = getClient().getBinder().getODataEntity( new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity))); assertEquals(entity, written); input.close(); @@ -364,12 +364,12 @@ public class EntityTest extends AbstractTest { private void derived(final ODataClient client, final ODataFormat format) throws Exception { final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format)); - final ODataEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input)); + final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input)); assertNotNull(entity); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress", - ((ODataValuable) entity.getProperty("HomeAddress")).getValue().getTypeName()); + ((ClientValuable) entity.getProperty("HomeAddress")).getValue().getTypeName()); input.close(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java index c0067bc..21b1f82 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ErrorTest.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.v4; import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.core.AbstractTest; -import org.apache.olingo.commons.api.domain.ODataError; +import org.apache.olingo.commons.api.domain.ClientError; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; import org.junit.Test; @@ -35,15 +35,15 @@ public class ErrorTest extends AbstractTest { return v4Client; } - private ODataError error(final String name, final ODataFormat format) throws ODataDeserializerException { - final ODataError error = getClient().getDeserializer(format).toError( + private ClientError error(final String name, final ODataFormat format) throws ODataDeserializerException { + final ClientError error = getClient().getDeserializer(format).toError( getClass().getResourceAsStream(name + "." + getSuffix(format))); assertNotNull(error); return error; } private void simple(final ODataFormat format) throws ODataDeserializerException { - final ODataError error = error("error", format); + final ClientError error = error("error", format); assertEquals("501", error.getCode()); assertEquals("Unsupported functionality", error.getMessage()); assertEquals("query", error.getTarget()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 0f6cb19..49c7c38 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 @@ -35,10 +35,10 @@ import org.apache.olingo.client.core.AbstractTest; import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.data.Delta; 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.ODataValue; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ODataFormat; import org.junit.Test; @@ -225,21 +225,21 @@ public class JSONTest extends AbstractTest { @Test public void issueOLINGO390() throws Exception { - final ODataEntity message = getClient().getObjectFactory(). + final ClientEntity message = getClient().getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.Exchange.Services.OData.Model.Message")); - final ODataComplexValue toRecipient = getClient().getObjectFactory(). + final ClientComplexValue toRecipient = getClient().getObjectFactory(). newComplexValue("Microsoft.Exchange.Services.OData.Model.Recipient"); toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Name", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challen_olingo_client"))); toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Address", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]"))); - final ODataCollectionValue<ODataValue> toRecipients = getClient().getObjectFactory(). + final ClientCollectionValue<ClientValue> toRecipients = getClient().getObjectFactory(). newCollectionValue("Microsoft.Exchange.Services.OData.Model.Recipient"); toRecipients.add(toRecipient); message.getProperties().add(getClient().getObjectFactory().newCollectionProperty("ToRecipients", toRecipients)); - final ODataComplexValue body = + final ClientComplexValue 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/c37d4da5/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java index 5728812..760e8ca 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.v4; import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.core.AbstractTest; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; @@ -42,7 +42,7 @@ public class PrimitiveValueTest extends AbstractTest { expected.clear(); expected.set(2013, 0, 10, 21, 45, 17); - final ODataValue value = getClient().getObjectFactory().newPrimitiveValueBuilder(). + final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(expected).build(); assertEquals(EdmPrimitiveTypeKind.TimeOfDay, value.asPrimitive().getTypeKind()); @@ -60,7 +60,7 @@ public class PrimitiveValueTest extends AbstractTest { expected.clear(); expected.set(2013, 0, 10); - final ODataValue value = getClient().getObjectFactory().newPrimitiveValueBuilder(). + final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Date).setValue(expected).build(); assertEquals(EdmPrimitiveTypeKind.Date, value.asPrimitive().getTypeKind()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 642f37b..e8daeb8 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 @@ -20,10 +20,10 @@ package org.apache.olingo.client.core.v4; import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.core.AbstractTest; -import org.apache.olingo.commons.api.domain.ODataCollectionValue; -import org.apache.olingo.commons.api.domain.ODataComplexValue; -import org.apache.olingo.commons.api.domain.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; import org.apache.olingo.commons.api.serialization.ODataSerializerException; @@ -45,15 +45,15 @@ public class PropertyTest extends AbstractTest { private void _enum(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException { final InputStream input = getClass().getResourceAsStream("Products_5_SkinColor." + getSuffix(format)); - final ODataProperty property = getClient().getReader().readProperty(input, format); + final ClientProperty property = getClient().getReader().readProperty(input, format); assertNotNull(property); assertTrue(property.hasEnumValue()); - final ODataProperty written = getClient().getReader().readProperty( + final ClientProperty written = getClient().getReader().readProperty( getClient().getWriter().writeProperty(property, format), format); // This is needed because type information gets lost with serialization if (format == ODataFormat.XML) { - final ODataProperty comparable = getClient().getObjectFactory().newEnumProperty(property.getName(), + final ClientProperty comparable = getClient().getObjectFactory().newEnumProperty(property.getName(), getClient().getObjectFactory(). newEnumValue(property.getEnumValue().getTypeName(), written.getEnumValue().getValue())); @@ -73,21 +73,21 @@ public class PropertyTest extends AbstractTest { private void complex(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException { final InputStream input = getClass().getResourceAsStream("Employees_3_HomeAddress." + getSuffix(format)); - final ODataProperty property = getClient().getReader().readProperty(input, format); + final ClientProperty property = getClient().getReader().readProperty(input, format); assertNotNull(property); assertTrue(property.hasComplexValue()); assertEquals(3, property.getComplexValue().size()); - final ODataProperty written = getClient().getReader().readProperty( + final ClientProperty written = getClient().getReader().readProperty( getClient().getWriter().writeProperty(property, format), format); // This is needed because type information gets lost with JSON serialization - final ODataComplexValue typedValue = getClient().getObjectFactory(). + final ClientComplexValue typedValue = getClient().getObjectFactory(). newComplexValue(property.getComplexValue().getTypeName()); - for (final Iterator<ODataProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) { - final ODataProperty prop = itor.next(); + for (final Iterator<ClientProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) { + final ClientProperty prop = itor.next(); typedValue.add(prop); } - final ODataProperty comparable = getClient().getObjectFactory(). + final ClientProperty comparable = getClient().getObjectFactory(). newComplexProperty(property.getName(), typedValue); assertEquals(property, comparable); @@ -105,22 +105,22 @@ public class PropertyTest extends AbstractTest { private void collection(final ODataFormat format) throws ODataDeserializerException, ODataSerializerException { final InputStream input = getClass().getResourceAsStream("Products_5_CoverColors." + getSuffix(format)); - final ODataProperty property = getClient().getReader().readProperty(input, format); + final ClientProperty property = getClient().getReader().readProperty(input, format); assertNotNull(property); assertTrue(property.hasCollectionValue()); assertEquals(3, property.getCollectionValue().size()); - final ODataProperty written = getClient().getReader().readProperty( + final ClientProperty written = getClient().getReader().readProperty( getClient().getWriter().writeProperty(property, format), format); // This is needed because type information gets lost with JSON serialization if (format == ODataFormat.XML) { - final ODataCollectionValue<ODataValue> typedValue = getClient().getObjectFactory(). + final ClientCollectionValue<ClientValue> typedValue = getClient().getObjectFactory(). newCollectionValue(property.getCollectionValue().getTypeName()); - for (final Iterator<ODataValue> itor = written.getCollectionValue().iterator(); itor.hasNext();) { - final ODataValue value = itor.next(); + for (final Iterator<ClientValue> itor = written.getCollectionValue().iterator(); itor.hasNext();) { + final ClientValue value = itor.next(); typedValue.add(value); } - final ODataProperty comparable = getClient().getObjectFactory(). + final ClientProperty comparable = getClient().getObjectFactory(). newCollectionProperty(property.getName(), typedValue); assertEquals(property, comparable); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java index 096591c..e025076 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/ServiceDocumentTest.java @@ -22,7 +22,7 @@ import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.data.ServiceDocument; import org.apache.olingo.client.core.AbstractTest; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataServiceDocument; +import org.apache.olingo.commons.api.domain.ClientServiceDocument; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; import org.junit.Test; @@ -44,14 +44,14 @@ public class ServiceDocumentTest extends AbstractTest { return format == ODataFormat.XML ? "xml" : "json"; } - private ODataServiceDocument parse(final ODataFormat format) throws ODataDeserializerException { + private ClientServiceDocument parse(final ODataFormat format) throws ODataDeserializerException { ResWrap<ServiceDocument> service = getClient().getDeserializer(format).toServiceDocument( getClass().getResourceAsStream("serviceDocument." + getFileExtension(format))); assertEquals(URI.create("http://host/service/$metadata"), service.getContextURL()); assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", service.getMetadataETag()); - final ODataServiceDocument serviceDocument = getClient().getBinder().getODataServiceDocument(service.getPayload()); + final ClientServiceDocument serviceDocument = getClient().getBinder().getODataServiceDocument(service.getPayload()); assertNotNull(serviceDocument); assertTrue(serviceDocument.getEntitySetNames().contains("Order Details")); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java index 167c5c3..a9db524 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.commons.api.data; -import org.apache.olingo.commons.api.domain.ODataOperation; +import org.apache.olingo.commons.api.domain.ClientOperation; import java.net.URI; import java.util.ArrayList; @@ -33,7 +33,7 @@ public class Entity extends Linked { private Link editLink; private final List<Link> mediaEditLinks = new ArrayList<Link>(); - private final List<ODataOperation> operations = new ArrayList<ODataOperation>(); + private final List<ClientOperation> operations = new ArrayList<ClientOperation>(); private final List<Property> properties = new ArrayList<Property>(); @@ -122,7 +122,7 @@ public class Entity extends Linked { * * @return operations. */ - public List<ODataOperation> getOperations() { + public List<ClientOperation> getOperations() { return operations; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientPayload.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientPayload.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientPayload.java new file mode 100644 index 0000000..fc54860 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientPayload.java @@ -0,0 +1,50 @@ +/* + * 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; + +import java.net.URI; + +/** + * OData entity. + */ +public abstract class AbstractClientPayload extends ClientItem { + + /** + * Context URL. + */ + private URI contextURL; + + public AbstractClientPayload(final String name) { + super(name); + } + + /** + * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a + * fragment identifying the relevant portion of the metadata document. + * + * @return context URL. + */ + public URI getContextURL() { + return contextURL; + } + + public void setContextURL(final URI contextURL) { + this.contextURL = contextURL; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientValue.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientValue.java new file mode 100644 index 0000000..af5b423 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractClientValue.java @@ -0,0 +1,120 @@ +/* + * 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; + +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; + +/** + * Abstract representation of an OData entity property value. + */ +public abstract class AbstractClientValue implements ClientValue { + + /** + * Type name; + */ + private final String typeName; + + public AbstractClientValue(final String typeName) { + this.typeName = typeName; + } + + @Override + public String getTypeName() { + return typeName; + } + + /** + * Check is is a primitive value. + * + * @return 'TRUE' if primitive; 'FALSE' otherwise. + */ + @Override + public boolean isPrimitive() { + return (this instanceof ClientPrimitiveValue); + } + + /** + * Casts to primitive value. + * + * @return primitive value. + */ + @Override + public ClientPrimitiveValue asPrimitive() { + return isPrimitive() ? (ClientPrimitiveValue) this : null; + } + + /** + * Check is is a complex value. + * + * @return 'TRUE' if complex; 'FALSE' otherwise. + */ + @Override + public boolean isComplex() { + return (this instanceof ClientComplexValue); + } + + /** + * Casts to complex value. + * + * @return complex value. + */ + @Override + public ClientComplexValue asComplex() { + return isComplex() ? (ClientComplexValue) this : null; + } + + /** + * Check is is a collection value. + * + * @return 'TRUE' if collection; 'FALSE' otherwise. + */ + @Override + public boolean isCollection() { + return (this instanceof ClientCollectionValue); + } + + /** + * Casts to collection value. + * + * @return collection value. + */ + @SuppressWarnings("unchecked") + @Override + public <OV extends ClientValue> ClientCollectionValue<OV> asCollection() { + return isCollection() ? (ClientCollectionValue<OV>) this : null; + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataPayload.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataPayload.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataPayload.java deleted file mode 100644 index 62cb4e1..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataPayload.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.api.domain; - -import java.net.URI; - -/** - * OData entity. - */ -public abstract class AbstractODataPayload extends ODataItem { - - /** - * Context URL. - */ - private URI contextURL; - - public AbstractODataPayload(final String name) { - super(name); - } - - /** - * The context URL describes the content of the payload. It consists of the canonical metadata document URL and a - * fragment identifying the relevant portion of the metadata document. - * - * @return context URL. - */ - public URI getContextURL() { - return contextURL; - } - - public void setContextURL(final URI contextURL) { - this.contextURL = contextURL; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 deleted file mode 100644 index acd056d..0000000 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java +++ /dev/null @@ -1,120 +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; - -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; - -/** - * Abstract representation of an OData entity property value. - */ -public abstract class AbstractODataValue implements ODataValue { - - /** - * Type name; - */ - private final String typeName; - - public AbstractODataValue(final String typeName) { - this.typeName = typeName; - } - - @Override - public String getTypeName() { - return typeName; - } - - /** - * Check is is a primitive value. - * - * @return 'TRUE' if primitive; 'FALSE' otherwise. - */ - @Override - public boolean isPrimitive() { - return (this instanceof ODataPrimitiveValue); - } - - /** - * Casts to primitive value. - * - * @return primitive value. - */ - @Override - public ODataPrimitiveValue asPrimitive() { - return isPrimitive() ? (ODataPrimitiveValue) this : null; - } - - /** - * Check is is a complex value. - * - * @return 'TRUE' if complex; 'FALSE' otherwise. - */ - @Override - public boolean isComplex() { - return (this instanceof ODataComplexValue); - } - - /** - * Casts to complex value. - * - * @return complex value. - */ - @Override - public ODataComplexValue asComplex() { - return isComplex() ? (ODataComplexValue) this : null; - } - - /** - * Check is is a collection value. - * - * @return 'TRUE' if collection; 'FALSE' otherwise. - */ - @Override - public boolean isCollection() { - return (this instanceof ODataCollectionValue); - } - - /** - * Casts to collection value. - * - * @return collection value. - */ - @SuppressWarnings("unchecked") - @Override - public <OV extends ODataValue> ODataCollectionValue<OV> asCollection() { - return isCollection() ? (ODataCollectionValue<OV>) this : null; - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotatable.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotatable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotatable.java new file mode 100644 index 0000000..f9c5119 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotatable.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.domain; + +import java.util.List; + +public interface ClientAnnotatable { + + List<ClientAnnotation> getAnnotations(); +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotation.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotation.java new file mode 100644 index 0000000..1749c63 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ClientAnnotation.java @@ -0,0 +1,30 @@ +/* + * 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 ClientAnnotation extends ClientValuable { + + /** + * Returns annotation name. + * + * @return annotation name. + */ + String getTerm(); + +}
