olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sklev...@apache.org
Subject [01/51] [abbrv] [OLINGO-200] Introducing interfaces for domain object
Date Fri, 04 Apr 2014 05:26:05 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/olingo-206-validator b25080359 -> 6d66ff391


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ceda4740/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
new file mode 100644
index 0000000..1189aae
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
@@ -0,0 +1,90 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataValue;
+
+/**
+ * OData collection property value.
+ */
+public class ODataCollectionValueImpl extends AbstractODataValue implements ODataCollectionValue
{
+
+  private static final long serialVersionUID = -3665659846001987187L;
+
+  /**
+   * Values.
+   */
+  private final List<ODataValue> values = new ArrayList<ODataValue>();
+
+  /**
+   * Constructor.
+   *
+   * @param typeName type name.
+   */
+  public ODataCollectionValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+  /**
+   * Adds a value to the collection.
+   *
+   * @param value value to be added.
+   */
+  @Override
+  public void add(final ODataValue value) {
+    if (value.isPrimitive() || value.isComplex()) {
+      values.add(value);
+    }
+  }
+
+  /**
+   * Value iterator.
+   *
+   * @return value iterator.
+   */
+  @Override
+  public Iterator<ODataValue> iterator() {
+    return values.iterator();
+  }
+
+  /**
+   * Gets collection size.
+   *
+   * @return collection size.
+   */
+  @Override
+  public int size() {
+    return values.size();
+  }
+
+  /**
+   * Checks if collection is empty.
+   *
+   * @return 'TRUE' if empty; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isEmpty() {
+    return values.isEmpty();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ceda4740/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
new file mode 100644
index 0000000..07d6055
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.util.Iterator;
+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;
+
+/**
+ * OData complex property value.
+ */
+public class ODataComplexValueImpl extends AbstractODataValue implements ODataComplexValue
{
+
+  private static final long serialVersionUID = -1878555027714020431L;
+
+  /**
+   * Complex type fields.
+   */
+  private final Map<String, ODataProperty> fields = new LinkedHashMap<String, ODataProperty>();
+
+  /**
+   * Constructor.
+   *
+   * @param typeName type name.
+   */
+  public ODataComplexValueImpl(final String typeName) {
+    super(typeName);
+  }
+
+  /**
+   * Adds field to the complex type.
+   *
+   * @param field field to be added.
+   */
+  @Override
+  public void add(final ODataProperty field) {
+    fields.put(field.getName(), field);
+  }
+
+  /**
+   * Gets field.
+   *
+   * @param name name of the field to be retrieved.
+   * @return requested field.
+   */
+  @Override
+  public ODataProperty get(final String name) {
+    return fields.get(name);
+  }
+
+  /**
+   * Complex property fields iterator.
+   *
+   * @return fields iterator.
+   */
+  @Override
+  public Iterator<ODataProperty> iterator() {
+    return fields.values().iterator();
+  }
+
+  /**
+   * Gets number of fields.
+   *
+   * @return number of fields.
+   */
+  @Override
+  public int size() {
+    return fields.size();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ceda4740/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
new file mode 100644
index 0000000..62d1e42
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
@@ -0,0 +1,372 @@
+/*
+ * 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/ceda4740/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
new file mode 100644
index 0000000..b7246d1
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java
@@ -0,0 +1,104 @@
+/*
+ * 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/ceda4740/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
new file mode 100644
index 0000000..63a47ce
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
@@ -0,0 +1,171 @@
+/*
+ * 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/ceda4740/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
index ad60494..965d5fc 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
@@ -139,6 +139,15 @@ public class ODataPrimitiveValueImpl extends AbstractODataValue implements
OData
    */
   private Object value;
 
+  private ODataPrimitiveValueImpl() {
+    super(null);
+  }
+
+  @Override
+  public String getTypeName() {
+    return typeKind.getFullQualifiedName().toString();
+  }
+
   @Override
   public EdmPrimitiveTypeKind getTypeKind() {
     return typeKind;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ceda4740/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
new file mode 100644
index 0000000..4c8aea9
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPropertyImpl.java
@@ -0,0 +1,172 @@
+/*
+ * 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/ceda4740/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ODataObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ODataObjectFactoryImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ODataObjectFactoryImpl.java
deleted file mode 100644
index ae946e0..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/ODataObjectFactoryImpl.java
+++ /dev/null
@@ -1,156 +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.op;
-
-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 ODataEntitySet();
-  }
-
-  @Override
-  public ODataEntitySet newEntitySet(final URI next) {
-    return new ODataEntitySet(next);
-  }
-
-  @Override
-  public ODataEntity newEntity(final String name) {
-    return new ODataEntity(name);
-  }
-
-  @Override
-  public ODataEntity newEntity(final String name, final URI link) {
-    final ODataEntity result = new ODataEntity(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 ODataProperty newPrimitiveProperty(final String name, final ODataPrimitiveValue
value) {
-    return new ODataProperty(name, value);
-  }
-
-  @Override
-  public ODataProperty newComplexProperty(final String name, final ODataComplexValue value)
{
-    return new ODataProperty(name, value);
-  }
-
-  @Override
-  public ODataProperty newCollectionProperty(final String name, final ODataCollectionValue
value) {
-    return new ODataProperty(name, value);
-  }
-
-}


Mime
View raw message