You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/01 16:18:56 UTC
[29/51] [abbrv] [OLINGO-200] Introducing specialization for V3 and V4
domain objects
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
new file mode 100644
index 0000000..a1b729f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntity.java
@@ -0,0 +1,326 @@
+/*
+ * 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.domain;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.domain.AbstractODataPayload;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataOperation;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+
+/**
+ * OData entity.
+ */
+public abstract class AbstractODataEntity extends AbstractODataPayload implements CommonODataEntity {
+
+ private static final long serialVersionUID = 8360640095932811034L;
+
+ /**
+ * ETag.
+ */
+ private String eTag;
+
+ /**
+ * Media entity flag.
+ */
+ private boolean mediaEntity = false;
+
+ /**
+ * In case of media entity, media content type.
+ */
+ private String mediaContentType;
+
+ /**
+ * In case of media entity, media content source.
+ */
+ private String mediaContentSource;
+
+ /**
+ * Edit link.
+ */
+ private URI editLink;
+
+ /**
+ * Navigation links (might contain in-line entities or feeds).
+ */
+ private final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
+
+ /**
+ * Association links.
+ */
+ private final List<ODataLink> associationLinks = new ArrayList<ODataLink>();
+
+ /**
+ * Media edit links.
+ */
+ private final List<ODataLink> editMediaLinks = new ArrayList<ODataLink>();
+
+ /**
+ * Operations (legacy, functions, actions).
+ */
+ private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
+
+ /**
+ * Constructor.
+ *
+ * @param name OData entity name.
+ */
+ public AbstractODataEntity(final String name) {
+ super(name);
+ }
+
+ /**
+ * Gets ETag.
+ *
+ * @return ETag.
+ */
+ @Override
+ public String getETag() {
+ return eTag;
+ }
+
+ /**
+ * Sets ETag.
+ *
+ * @param eTag ETag.
+ */
+ @Override
+ public void setETag(final String eTag) {
+ this.eTag = eTag;
+ }
+
+ /**
+ * Searches for operation with given title.
+ *
+ * @param title operation to look for
+ * @return operation if found with given title, <tt>null</tt> otherwise
+ */
+ @Override
+ public ODataOperation getOperation(final String title) {
+ ODataOperation result = null;
+ for (ODataOperation operation : operations) {
+ if (title.equals(operation.getTitle())) {
+ result = operation;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets operations.
+ *
+ * @return operations.
+ */
+ @Override
+ public List<ODataOperation> getOperations() {
+ return this.operations;
+ }
+
+ /**
+ * Searches for property with given name.
+ *
+ * @param name property to look for
+ * @return property if found with given name, <tt>null</tt> otherwise
+ */
+ @Override
+ public CommonODataProperty getProperty(final String name) {
+ CommonODataProperty result = null;
+
+ if (StringUtils.isNotBlank(name)) {
+ for (CommonODataProperty property : getProperties()) {
+ if (name.equals(property.getName())) {
+ result = property;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Puts the given link into one of available lists, based on its type.
+ *
+ * @param link to be added
+ * @return <tt>true</tt> if the given link was added in one of available lists
+ */
+ @Override
+ public boolean addLink(final ODataLink link) {
+ boolean result = false;
+
+ switch (link.getType()) {
+ case ASSOCIATION:
+ result = associationLinks.contains(link) ? false : associationLinks.add(link);
+ break;
+
+ case ENTITY_NAVIGATION:
+ case ENTITY_SET_NAVIGATION:
+ result = navigationLinks.contains(link) ? false : navigationLinks.add(link);
+ break;
+
+ case MEDIA_EDIT:
+ result = editMediaLinks.contains(link) ? false : editMediaLinks.add(link);
+ break;
+
+ default:
+ }
+
+ return result;
+ }
+
+ /**
+ * Removes the given link from any list (association, navigation, edit-media).
+ *
+ * @param link to be removed
+ * @return <tt>true</tt> if the given link was contained in one of available lists
+ */
+ @Override
+ public boolean removeLink(final ODataLink link) {
+ return associationLinks.remove(link) || navigationLinks.remove(link) || editMediaLinks.remove(link);
+ }
+
+ /**
+ * Returns all entity navigation links (including inline entities / feeds).
+ *
+ * @return OData entity links.
+ */
+ @Override
+ public List<ODataLink> getNavigationLinks() {
+ return navigationLinks;
+ }
+
+ /**
+ * Returns all entity association links.
+ *
+ * @return OData entity links.
+ */
+ @Override
+ public List<ODataLink> getAssociationLinks() {
+ return associationLinks;
+ }
+
+ /**
+ * Returns all entity media edit links.
+ *
+ * @return OData entity links.
+ */
+ @Override
+ public List<ODataLink> getEditMediaLinks() {
+ return editMediaLinks;
+ }
+
+ /**
+ * Returns OData entity edit link.
+ *
+ * @return entity edit link.
+ */
+ @Override
+ public URI getEditLink() {
+ return editLink;
+ }
+
+ /**
+ * Sets OData entity edit link.
+ *
+ * @param editLink edit link.
+ */
+ @Override
+ public void setEditLink(final URI editLink) {
+ this.editLink = editLink;
+ }
+
+ @Override
+ public URI getLink() {
+ return super.getLink() == null ? getEditLink() : super.getLink();
+ }
+
+ /**
+ * TRUE if read-only entity.
+ *
+ * @return TRUE if read-only; FALSE otherwise.
+ */
+ @Override
+ public boolean isReadOnly() {
+ return super.getLink() != null;
+ }
+
+ /**
+ * Checks if the current entity is a media entity.
+ *
+ * @return 'TRUE' if media entity; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean isMediaEntity() {
+ return mediaEntity;
+ }
+
+ /**
+ * Sets media entity flag.
+ *
+ * @param isMediaEntity media entity flag value.
+ */
+ @Override
+ public void setMediaEntity(final boolean isMediaEntity) {
+ this.mediaEntity = isMediaEntity;
+ }
+
+ /**
+ * Gets media content type.
+ *
+ * @return media content type.
+ */
+ @Override
+ public String getMediaContentType() {
+ return mediaContentType;
+ }
+
+ /**
+ * Sets media content type.
+ *
+ * @param mediaContentType media content type.
+ */
+ @Override
+ public void setMediaContentType(final String mediaContentType) {
+ this.mediaContentType = mediaContentType;
+ }
+
+ /**
+ * Gets media content source.
+ *
+ * @return media content source.
+ */
+ @Override
+ public String getMediaContentSource() {
+ return mediaContentSource;
+ }
+
+ /**
+ * Sets media content source.
+ *
+ * @param mediaContentSource media content source.
+ */
+ @Override
+ public void setMediaContentSource(final String mediaContentSource) {
+ this.mediaContentSource = mediaContentSource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
new file mode 100644
index 0000000..b2f7dc8
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataEntitySet.java
@@ -0,0 +1,73 @@
+/*
+ * 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.domain;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.domain.AbstractODataPayload;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+
+public abstract class AbstractODataEntitySet extends AbstractODataPayload implements CommonODataEntitySet {
+
+ private static final long serialVersionUID = 9039605899821494024L;
+
+ /**
+ * Link to the next page.
+ */
+ private URI next;
+
+ /**
+ * Number of ODataEntities contained in this feed. If <tt>$inlinecount</tt> was requested, this value comes from
+ * there.
+ */
+ private Integer count;
+
+ /**
+ * Constructor.
+ */
+ public AbstractODataEntitySet() {
+ super(null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param next next link.
+ */
+ public AbstractODataEntitySet(final URI next) {
+ super(null);
+ this.next = next;
+ }
+
+ @Override
+ public URI getNext() {
+ return next;
+ }
+
+ protected abstract int getEntitiesSize();
+
+ @Override
+ public int getCount() {
+ return count == null ? getEntitiesSize() : count;
+ }
+
+ @Override
+ public void setCount(final int count) {
+ this.count = count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
new file mode 100644
index 0000000..ea73910
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataObjectFactory.java
@@ -0,0 +1,133 @@
+/*
+ * 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.domain;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+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.CommonODataObjectFactory;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public abstract class AbstractODataObjectFactory implements CommonODataObjectFactory {
+
+ private static final long serialVersionUID = -3769695665946919447L;
+
+ protected final ODataServiceVersion version;
+
+ public AbstractODataObjectFactory(final ODataServiceVersion version) {
+ this.version = version;
+ }
+
+ @Override
+ public ODataInlineEntitySet newInlineEntitySet(final String name, final URI link,
+ final CommonODataEntitySet entitySet) {
+
+ return new ODataInlineEntitySet(version, link, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
+ }
+
+ @Override
+ public ODataInlineEntitySet newInlineEntitySet(final String name, final URI baseURI, final String href,
+ final CommonODataEntitySet entitySet) {
+
+ return new ODataInlineEntitySet(version, baseURI, href, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
+ }
+
+ @Override
+ public ODataInlineEntity newInlineEntity(final String name, final URI link, final CommonODataEntity entity) {
+ return new ODataInlineEntity(version, link, ODataLinkType.ENTITY_NAVIGATION, name, entity);
+ }
+
+ @Override
+ public ODataInlineEntity newInlineEntity(final String name, final URI baseURI, final String href,
+ final CommonODataEntity entity) {
+
+ return new ODataInlineEntity(version, baseURI, href, ODataLinkType.ENTITY_NAVIGATION, name, entity);
+ }
+
+ @Override
+ public ODataLink newEntityNavigationLink(final String name, final URI link) {
+ return new ODataLink.Builder().setVersion(version).setURI(link).
+ setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newEntityNavigationLink(final String name, final URI baseURI, final String href) {
+ return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
+ setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newFeedNavigationLink(final String name, final URI link) {
+ return new ODataLink.Builder().setVersion(version).setURI(link).
+ setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newFeedNavigationLink(final String name, final URI baseURI, final String href) {
+ return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
+ setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newAssociationLink(final String name, final URI link) {
+ return new ODataLink.Builder().setVersion(version).setURI(link).
+ setType(ODataLinkType.ASSOCIATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newAssociationLink(final String name, final URI baseURI, final String href) {
+ return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
+ setType(ODataLinkType.ASSOCIATION).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newMediaEditLink(final String name, final URI link) {
+ return new ODataLink.Builder().setVersion(version).setURI(link).
+ setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
+ }
+
+ @Override
+ public ODataLink newMediaEditLink(final String name, final URI baseURI, final String href) {
+ return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
+ setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
+ }
+
+ @Override
+ public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
+ return new ODataPrimitiveValueImpl.BuilderImpl(version);
+ }
+
+ @Override
+ public ODataComplexValue newComplexValue(final String typeName) {
+ return new ODataComplexValueImpl(typeName);
+ }
+
+ @Override
+ public ODataCollectionValue newCollectionValue(final String typeName) {
+ return new ODataCollectionValueImpl(typeName);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
new file mode 100644
index 0000000..c68dfab
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataProperty.java
@@ -0,0 +1,169 @@
+/*
+ * 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.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;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataValue;
+
+public abstract class AbstractODataProperty implements CommonODataProperty {
+
+ private static final long serialVersionUID = 926939448778950450L;
+
+ /**
+ * Property name.
+ */
+ private final String name;
+
+ /**
+ * Property value.
+ */
+ private final ODataValue value;
+
+ /**
+ * Constructor.
+ *
+ * @param name property name.
+ * @param value property value.
+ */
+ public AbstractODataProperty(final String name, final ODataValue value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns property name.
+ *
+ * @return property name.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns property value.
+ *
+ * @return property value.
+ */
+ @Override
+ public ODataValue getValue() {
+ return value;
+ }
+
+ /**
+ * Checks if has null value.
+ *
+ * @return 'TRUE' if has null value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasNullValue() {
+ return this.value == null;
+ }
+
+ /**
+ * Checks if has primitive value.
+ *
+ * @return 'TRUE' if has primitive value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasPrimitiveValue() {
+ return !hasNullValue() && this.value.isPrimitive();
+ }
+
+ /**
+ * Gets primitive value.
+ *
+ * @return primitive value if exists; null otherwise.
+ */
+ @Override
+ public ODataPrimitiveValue getPrimitiveValue() {
+ return hasPrimitiveValue() ? this.value.asPrimitive() : null;
+ }
+
+ /**
+ * Checks if has complex value.
+ *
+ * @return 'TRUE' if has complex value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasComplexValue() {
+ return !hasNullValue() && this.value.isComplex();
+ }
+
+ /**
+ * Gets complex value.
+ *
+ * @return complex value if exists; null otherwise.
+ */
+ @Override
+ public ODataComplexValue getComplexValue() {
+ return hasComplexValue() ? this.value.asComplex() : null;
+ }
+
+ /**
+ * Checks if has collection value.
+ *
+ * @return 'TRUE' if has collection value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasCollectionValue() {
+ return !hasNullValue() && this.value.isCollection();
+ }
+
+ /**
+ * Gets collection value.
+ *
+ * @return collection value if exists; null otherwise.
+ */
+ @Override
+ public ODataCollectionValue getCollectionValue() {
+ return hasCollectionValue() ? this.value.asCollection() : null;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/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 07d6055..ba8fe56 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
@@ -23,7 +23,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.olingo.commons.api.domain.AbstractODataValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData complex property value.
@@ -35,7 +35,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
/**
* Complex type fields.
*/
- private final Map<String, ODataProperty> fields = new LinkedHashMap<String, ODataProperty>();
+ private final Map<String, CommonODataProperty> fields = new LinkedHashMap<String, CommonODataProperty>();
/**
* Constructor.
@@ -52,7 +52,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @param field field to be added.
*/
@Override
- public void add(final ODataProperty field) {
+ public void add(final CommonODataProperty field) {
fields.put(field.getName(), field);
}
@@ -63,7 +63,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @return requested field.
*/
@Override
- public ODataProperty get(final String name) {
+ public CommonODataProperty get(final String name) {
return fields.get(name);
}
@@ -73,7 +73,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
* @return fields iterator.
*/
@Override
- public Iterator<ODataProperty> iterator() {
+ public Iterator<CommonODataProperty> iterator() {
return fields.values().iterator();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
deleted file mode 100644
index 62d1e42..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
+++ /dev/null
@@ -1,372 +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.domain;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.domain.AbstractODataPayload;
-import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.domain.ODataProperty;
-
-/**
- * OData entity.
- */
-public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity {
-
- private static final long serialVersionUID = 8360640095932811034L;
-
- /**
- * Entity reference.
- */
- private String reference;
-
- /**
- * ETag.
- */
- private String eTag;
-
- /**
- * Media entity flag.
- */
- private boolean mediaEntity = false;
-
- /**
- * In case of media entity, media content type.
- */
- private String mediaContentType;
-
- /**
- * In case of media entity, media content source.
- */
- private String mediaContentSource;
-
- /**
- * Edit link.
- */
- private URI editLink;
-
- /**
- * Navigation links (might contain in-line entities or feeds).
- */
- private final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
-
- /**
- * Association links.
- */
- private final List<ODataLink> associationLinks = new ArrayList<ODataLink>();
-
- /**
- * Media edit links.
- */
- private final List<ODataLink> editMediaLinks = new ArrayList<ODataLink>();
-
- /**
- * Operations (legacy, functions, actions).
- */
- private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
-
- /**
- * Entity properties.
- */
- private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
-
- /**
- * Constructor.
- *
- * @param name OData entity name.
- */
- public ODataEntityImpl(final String name) {
- super(name);
- }
-
- /**
- * To request entity references in place of the actual entities, the client issues a GET request with /$ref appended
- * to the resource path.
- * <br />
- * If the resource path does not identify an entity or a collection of entities, the service returns 404 Not Found.
- * <br />
- * If the resource path terminates on a collection, the response MUST be the format-specific representation of a
- * collection of entity references pointing to the related entities. If no entities are related, the response is the
- * format-specific representation of an empty collection.
- * <br />
- * If the resource path terminates on a single entity, the response MUST be the format-specific representation of an
- * entity reference pointing to the related single entity. If the resource path terminates on a single entity and no
- * such entity exists, the service returns 404 Not Found.
- *
- * @return entity reference.
- */
- @Override
- public String getReference() {
- return reference;
- }
-
- @Override
- public void setReference(final String reference) {
- this.reference = reference;
- }
-
- /**
- * Gets ETag.
- *
- * @return ETag.
- */
- @Override
- public String getETag() {
- return eTag;
- }
-
- /**
- * Sets ETag.
- *
- * @param eTag ETag.
- */
- @Override
- public void setETag(final String eTag) {
- this.eTag = eTag;
- }
-
- /**
- * Searches for operation with given title.
- *
- * @param title operation to look for
- * @return operation if found with given title, <tt>null</tt> otherwise
- */
- @Override
- public ODataOperation getOperation(final String title) {
- ODataOperation result = null;
- for (ODataOperation operation : operations) {
- if (title.equals(operation.getTitle())) {
- result = operation;
- }
- }
-
- return result;
- }
-
- /**
- * Gets operations.
- *
- * @return operations.
- */
- @Override
- public List<ODataOperation> getOperations() {
- return this.operations;
- }
-
- /**
- * Searches for property with given name.
- *
- * @param name property to look for
- * @return property if found with given name, <tt>null</tt> otherwise
- */
- @Override
- public ODataProperty getProperty(final String name) {
- ODataProperty result = null;
-
- if (StringUtils.isNotBlank(name)) {
- for (ODataProperty property : properties) {
- if (name.equals(property.getName())) {
- result = property;
- }
- }
- }
-
- return result;
- }
-
- /**
- * Returns OData entity properties.
- *
- * @return OData entity properties.
- */
- @Override
- public List<ODataProperty> getProperties() {
- return properties;
- }
-
- /**
- * Puts the given link into one of available lists, based on its type.
- *
- * @param link to be added
- * @return <tt>true</tt> if the given link was added in one of available lists
- */
- @Override
- public boolean addLink(final ODataLink link) {
- boolean result = false;
-
- switch (link.getType()) {
- case ASSOCIATION:
- result = associationLinks.contains(link) ? false : associationLinks.add(link);
- break;
-
- case ENTITY_NAVIGATION:
- case ENTITY_SET_NAVIGATION:
- result = navigationLinks.contains(link) ? false : navigationLinks.add(link);
- break;
-
- case MEDIA_EDIT:
- result = editMediaLinks.contains(link) ? false : editMediaLinks.add(link);
- break;
-
- default:
- }
-
- return result;
- }
-
- /**
- * Removes the given link from any list (association, navigation, edit-media).
- *
- * @param link to be removed
- * @return <tt>true</tt> if the given link was contained in one of available lists
- */
- @Override
- public boolean removeLink(final ODataLink link) {
- return associationLinks.remove(link) || navigationLinks.remove(link) || editMediaLinks.remove(link);
- }
-
- /**
- * Returns all entity navigation links (including inline entities / feeds).
- *
- * @return OData entity links.
- */
- @Override
- public List<ODataLink> getNavigationLinks() {
- return navigationLinks;
- }
-
- /**
- * Returns all entity association links.
- *
- * @return OData entity links.
- */
- @Override
- public List<ODataLink> getAssociationLinks() {
- return associationLinks;
- }
-
- /**
- * Returns all entity media edit links.
- *
- * @return OData entity links.
- */
- @Override
- public List<ODataLink> getEditMediaLinks() {
- return editMediaLinks;
- }
-
- /**
- * Returns OData entity edit link.
- *
- * @return entity edit link.
- */
- @Override
- public URI getEditLink() {
- return editLink;
- }
-
- /**
- * Sets OData entity edit link.
- *
- * @param editLink edit link.
- */
- @Override
- public void setEditLink(final URI editLink) {
- this.editLink = editLink;
- }
-
- @Override
- public URI getLink() {
- return super.getLink() == null ? getEditLink() : super.getLink();
- }
-
- /**
- * TRUE if read-only entity.
- *
- * @return TRUE if read-only; FALSE otherwise.
- */
- @Override
- public boolean isReadOnly() {
- return super.getLink() != null;
- }
-
- /**
- * Checks if the current entity is a media entity.
- *
- * @return 'TRUE' if media entity; 'FALSE' otherwise.
- */
- @Override
- public boolean isMediaEntity() {
- return mediaEntity;
- }
-
- /**
- * Sets media entity flag.
- *
- * @param isMediaEntity media entity flag value.
- */
- @Override
- public void setMediaEntity(final boolean isMediaEntity) {
- this.mediaEntity = isMediaEntity;
- }
-
- /**
- * Gets media content type.
- *
- * @return media content type.
- */
- @Override
- public String getMediaContentType() {
- return mediaContentType;
- }
-
- /**
- * Sets media content type.
- *
- * @param mediaContentType media content type.
- */
- @Override
- public void setMediaContentType(final String mediaContentType) {
- this.mediaContentType = mediaContentType;
- }
-
- /**
- * Gets media content source.
- *
- * @return media content source.
- */
- @Override
- public String getMediaContentSource() {
- return mediaContentSource;
- }
-
- /**
- * Sets media content source.
- *
- * @param mediaContentSource media content source.
- */
- @Override
- public void setMediaContentSource(final String mediaContentSource) {
- this.mediaContentSource = mediaContentSource;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java
deleted file mode 100644
index b7246d1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java
+++ /dev/null
@@ -1,104 +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.domain;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.domain.AbstractODataPayload;
-import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataEntitySet;
-
-public class ODataEntitySetImpl extends AbstractODataPayload implements ODataEntitySet {
-
- private static final long serialVersionUID = 9039605899821494024L;
-
- /**
- * Link to the next page.
- */
- private URI next;
-
- /**
- * Number of ODataEntities contained in this feed. If <tt>$inlinecount</tt> was requested, this value comes from
- * there.
- */
- private Integer count;
-
- /**
- * OData entities contained in this feed.
- */
- private List<ODataEntity> entities = new ArrayList<ODataEntity>();
-
- /**
- * Constructor.
- */
- public ODataEntitySetImpl() {
- super(null);
- }
-
- /**
- * Constructor.
- *
- * @param next next link.
- */
- public ODataEntitySetImpl(final URI next) {
- super(null);
- this.next = next;
- }
-
- /**
- * Gets next page link.
- *
- * @return next page link; null value if single page or last page reached.
- */
- @Override
- public URI getNext() {
- return next;
- }
-
- /**
- * Gets contained entities.
- *
- * @return feed entries.
- */
- @Override
- public List<ODataEntity> getEntities() {
- return entities;
- }
-
- /**
- * Gets in-line count.
- *
- * @return in-line count value.
- */
- @Override
- public int getCount() {
- return count == null ? entities.size() : count;
- }
-
- /**
- * Sets in-line count.
- *
- * @param count in-line count value.
- */
- @Override
- public void setCount(final int count) {
- this.count = count;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/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
deleted file mode 100644
index 63a47ce..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
+++ /dev/null
@@ -1,171 +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.domain;
-
-import java.net.URI;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-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.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.ODataObjectFactory;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class ODataObjectFactoryImpl implements ODataObjectFactory {
-
- private static final long serialVersionUID = -3769695665946919447L;
-
- protected final ODataServiceVersion version;
-
- public ODataObjectFactoryImpl(final ODataServiceVersion version) {
- this.version = version;
- }
-
- @Override
- public ODataEntitySet newEntitySet() {
- return new ODataEntitySetImpl();
- }
-
- @Override
- public ODataEntitySet newEntitySet(final URI next) {
- return new ODataEntitySetImpl(next);
- }
-
- @Override
- public ODataEntity newEntity(final String name) {
- return new ODataEntityImpl(name);
- }
-
- @Override
- public ODataEntity newEntity(final String name, final URI link) {
- final ODataEntityImpl result = new ODataEntityImpl(name);
- result.setLink(link);
- return result;
- }
-
- @Override
- public ODataInlineEntitySet newInlineEntitySet(final String name, final URI link,
- final ODataEntitySet entitySet) {
-
- return new ODataInlineEntitySet(version, link, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
- }
-
- @Override
- public ODataInlineEntitySet newInlineEntitySet(final String name, final URI baseURI, final String href,
- final ODataEntitySet entitySet) {
-
- return new ODataInlineEntitySet(version, baseURI, href, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
- }
-
- @Override
- public ODataInlineEntity newInlineEntity(final String name, final URI link, final ODataEntity entity) {
- return new ODataInlineEntity(version, link, ODataLinkType.ENTITY_NAVIGATION, name, entity);
- }
-
- @Override
- public ODataInlineEntity newInlineEntity(final String name, final URI baseURI, final String href,
- final ODataEntity entity) {
-
- return new ODataInlineEntity(version, baseURI, href, ODataLinkType.ENTITY_NAVIGATION, name, entity);
- }
-
- @Override
- public ODataLink newEntityNavigationLink(final String name, final URI link) {
- return new ODataLink.Builder().setVersion(version).setURI(link).
- setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newEntityNavigationLink(final String name, final URI baseURI, final String href) {
- return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
- setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newFeedNavigationLink(final String name, final URI link) {
- return new ODataLink.Builder().setVersion(version).setURI(link).
- setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newFeedNavigationLink(final String name, final URI baseURI, final String href) {
- return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
- setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newAssociationLink(final String name, final URI link) {
- return new ODataLink.Builder().setVersion(version).setURI(link).
- setType(ODataLinkType.ASSOCIATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newAssociationLink(final String name, final URI baseURI, final String href) {
- return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
- setType(ODataLinkType.ASSOCIATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newMediaEditLink(final String name, final URI link) {
- return new ODataLink.Builder().setVersion(version).setURI(link).
- setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
- }
-
- @Override
- public ODataLink newMediaEditLink(final String name, final URI baseURI, final String href) {
- return new ODataLink.Builder().setVersion(version).setURI(baseURI, href).
- setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
- }
-
- @Override
- public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
- return new ODataPrimitiveValueImpl.BuilderImpl(version);
- }
-
- @Override
- public ODataComplexValue newComplexValue(final String typeName) {
- return new ODataComplexValueImpl(typeName);
- }
-
- @Override
- public ODataCollectionValue newCollectionValue(final String typeName) {
- return new ODataCollectionValueImpl(typeName);
- }
-
- @Override
- public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
- return new ODataPropertyImpl(name, value);
- }
-
- @Override
- public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
- return new ODataPropertyImpl(name, value);
- }
-
- @Override
- public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
- return new ODataPropertyImpl(name, value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/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
deleted file mode 100644
index 4c8aea9..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
+++ /dev/null
@@ -1,172 +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.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;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
-import org.apache.olingo.commons.api.domain.ODataValue;
-
-/**
- * OData entity property.
- */
-public class ODataPropertyImpl implements ODataProperty {
-
- private static final long serialVersionUID = 926939448778950450L;
-
- /**
- * Property name.
- */
- private final String name;
-
- /**
- * Property value.
- */
- private ODataValue value;
-
- /**
- * Constructor.
- *
- * @param name property name.
- * @param value property value.
- */
- public ODataPropertyImpl(final String name, final ODataValue value) {
- this.name = name;
- this.value = value;
- }
-
- /**
- * Returns property name.
- *
- * @return property name.
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Returns property value.
- *
- * @return property value.
- */
- @Override
- public ODataValue getValue() {
- return value;
- }
-
- /**
- * Checks if has null value.
- *
- * @return 'TRUE' if has null value; 'FALSE' otherwise.
- */
- @Override
- public boolean hasNullValue() {
- return this.value == null;
- }
-
- /**
- * Checks if has primitive value.
- *
- * @return 'TRUE' if has primitive value; 'FALSE' otherwise.
- */
- @Override
- public boolean hasPrimitiveValue() {
- return !hasNullValue() && this.value.isPrimitive();
- }
-
- /**
- * Gets primitive value.
- *
- * @return primitive value if exists; null otherwise.
- */
- @Override
- public ODataPrimitiveValue getPrimitiveValue() {
- return hasPrimitiveValue() ? this.value.asPrimitive() : null;
- }
-
- /**
- * Checks if has complex value.
- *
- * @return 'TRUE' if has complex value; 'FALSE' otherwise.
- */
- @Override
- public boolean hasComplexValue() {
- return !hasNullValue() && this.value.isComplex();
- }
-
- /**
- * Gets complex value.
- *
- * @return complex value if exists; null otherwise.
- */
- @Override
- public ODataComplexValue getComplexValue() {
- return hasComplexValue() ? this.value.asComplex() : null;
- }
-
- /**
- * Checks if has collection value.
- *
- * @return 'TRUE' if has collection value; 'FALSE' otherwise.
- */
- @Override
- public boolean hasCollectionValue() {
- return !hasNullValue() && this.value.isCollection();
- }
-
- /**
- * Gets collection value.
- *
- * @return collection value if exists; null otherwise.
- */
- @Override
- public ODataCollectionValue getCollectionValue() {
- return hasCollectionValue() ? this.value.asCollection() : null;
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public boolean equals(final Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public String toString() {
- return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java
new file mode 100644
index 0000000..8a41e7a
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntityImpl.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain.v3;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.core.domain.AbstractODataEntity;
+
+public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity {
+
+ private static final long serialVersionUID = 1728326493032709855L;
+
+ private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
+
+ public ODataEntityImpl(final String name) {
+ super(name);
+ }
+
+ @Override
+ public ODataProperty getProperty(final String name) {
+ return (ODataProperty) super.getProperty(name);
+ }
+
+ @Override
+ public List<ODataProperty> getProperties() {
+ return properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java
new file mode 100644
index 0000000..83870f3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataEntitySetImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.domain.v3;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.core.domain.AbstractODataEntitySet;
+
+public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataEntitySet {
+
+ private static final long serialVersionUID = -8127933181196033586L;
+
+ private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
+
+ public ODataEntitySetImpl() {
+ }
+
+ public ODataEntitySetImpl(final URI next) {
+ super(next);
+ }
+
+ @Override
+ protected int getEntitiesSize() {
+ return entities.size();
+ }
+
+ @Override
+ public List<ODataEntity> getEntities() {
+ return entities;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
new file mode 100644
index 0000000..2bfb8f5
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataObjectFactoryImpl.java
@@ -0,0 +1,75 @@
+/*
+ * 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.domain.v3;
+
+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.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory;
+
+public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implements ODataObjectFactory {
+
+ public ODataObjectFactoryImpl(final ODataServiceVersion version) {
+ super(version);
+ }
+
+ @Override
+ public ODataEntitySet newEntitySet() {
+ return new ODataEntitySetImpl();
+ }
+
+ @Override
+ public ODataEntitySet newEntitySet(final URI next) {
+ return new ODataEntitySetImpl(next);
+ }
+
+ @Override
+ public ODataEntity newEntity(final String name) {
+ return new ODataEntityImpl(name);
+ }
+
+ @Override
+ public ODataEntity newEntity(final String name, final URI link) {
+ final ODataEntityImpl result = new ODataEntityImpl(name);
+ result.setLink(link);
+ return result;
+ }
+
+ @Override
+ public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+ @Override
+ public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+ @Override
+ public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
new file mode 100644
index 0000000..68c44ec
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPropertyImpl.java
@@ -0,0 +1,33 @@
+/*
+ * 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.domain.v3;
+
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
+import org.apache.olingo.commons.core.domain.AbstractODataProperty;
+
+public class ODataPropertyImpl extends AbstractODataProperty implements ODataProperty {
+
+ private static final long serialVersionUID = 4851331227420757747L;
+
+ public ODataPropertyImpl(final String name, final ODataValue value) {
+ super(name, value);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java
new file mode 100644
index 0000000..b5ac799
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntityImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.domain.v4;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.core.domain.AbstractODataEntity;
+
+public class ODataEntityImpl extends AbstractODataEntity implements ODataEntity {
+
+ private static final long serialVersionUID = -3997704808753685990L;
+
+ /**
+ * Entity reference.
+ */
+ private String reference;
+
+ private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
+
+ public ODataEntityImpl(final String name) {
+ super(name);
+ }
+
+ @Override
+ public String getReference() {
+ return reference;
+ }
+
+ @Override
+ public void setReference(final String reference) {
+ this.reference = reference;
+ }
+
+ @Override
+ public ODataProperty getProperty(final String name) {
+ return (ODataProperty) super.getProperty(name);
+ }
+
+ @Override
+ public List<ODataProperty> getProperties() {
+ return properties;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
new file mode 100644
index 0000000..cbc5a04
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEntitySetImpl.java
@@ -0,0 +1,51 @@
+/*
+ * 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.domain.v4;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.core.domain.AbstractODataEntitySet;
+
+public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataEntitySet {
+
+ private static final long serialVersionUID = -8127933181196033586L;
+
+ private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
+
+ public ODataEntitySetImpl() {
+ }
+
+ public ODataEntitySetImpl(final URI next) {
+ super(next);
+ }
+
+ @Override
+ protected int getEntitiesSize() {
+ return entities.size();
+ }
+
+ @Override
+ public List<ODataEntity> getEntities() {
+ return entities;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
new file mode 100644
index 0000000..1b6428f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataObjectFactoryImpl.java
@@ -0,0 +1,81 @@
+/*
+ * 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.domain.v4;
+
+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.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.domain.AbstractODataObjectFactory;
+
+public class ODataObjectFactoryImpl extends AbstractODataObjectFactory implements ODataObjectFactory {
+
+ public ODataObjectFactoryImpl(final ODataServiceVersion version) {
+ super(version);
+ }
+
+ @Override
+ public ODataEntitySet newEntitySet() {
+ return new ODataEntitySetImpl();
+ }
+
+ @Override
+ public ODataEntitySet newEntitySet(final URI next) {
+ return new ODataEntitySetImpl(next);
+ }
+
+ @Override
+ public ODataEntity newEntity(final String name) {
+ return new ODataEntityImpl(name);
+ }
+
+ @Override
+ public ODataEntity newEntity(final String name, final URI link) {
+ final ODataEntityImpl result = new ODataEntityImpl(name);
+ result.setLink(link);
+ return result;
+ }
+
+ @Override
+ public ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+ @Override
+ public ODataProperty newComplexProperty(final String name, final ODataComplexValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+ @Override
+ public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+ @Override
+ public ODataProperty newEnumProperty(final String name, final ODataEnumValue value) {
+ return new ODataPropertyImpl(name, value);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/80e5ed56/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
new file mode 100644
index 0000000..fe6bf9d
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.domain.v4;
+
+import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.core.domain.AbstractODataProperty;
+
+public class ODataPropertyImpl extends AbstractODataProperty implements ODataProperty {
+
+ private static final long serialVersionUID = 4851331227420757747L;
+
+ public ODataPropertyImpl(final String name, final org.apache.olingo.commons.api.domain.ODataValue value) {
+ super(name, value);
+ }
+
+ @Override
+ public boolean hasEnumValue() {
+ return !hasNullValue() && getValue() instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+ && ((org.apache.olingo.commons.api.domain.v4.ODataValue) getValue()).isEnum();
+ }
+
+ @Override
+ public ODataEnumValue getEnumValue() {
+ return hasEnumValue() ? ((org.apache.olingo.commons.api.domain.v4.ODataValue) getValue()).asEnum() : null;
+ }
+
+}