You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/04/28 23:12:19 UTC
[03/17] olingo-odata4 git commit: [OLINGO-564] Renamed 'OData*' to
'Client*' classes
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java
new file mode 100644
index 0000000..a21f7ae
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.olingo.commons.api.domain.ClientAnnotation;
+import org.apache.olingo.commons.api.domain.ClientDeltaLink;
+import org.apache.olingo.commons.api.domain.ClientItem;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClientDeltaLinkImpl extends ClientItem implements ClientDeltaLink {
+
+ private URI source;
+
+ private String relationship;
+
+ private URI target;
+
+ private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
+
+ public ClientDeltaLinkImpl() {
+ super(null);
+ }
+
+ @Override
+ public URI getSource() {
+ return source;
+ }
+
+ @Override
+ public void setSource(final URI source) {
+ this.source = source;
+ }
+
+ @Override
+ public String getRelationship() {
+ return relationship;
+ }
+
+ @Override
+ public void setRelationship(final String relationship) {
+ this.relationship = relationship;
+ }
+
+ @Override
+ public URI getTarget() {
+ return target;
+ }
+
+ @Override
+ public void setTarget(final URI target) {
+ this.target = target;
+ }
+
+ @Override
+ public List<ClientAnnotation> getAnnotations() {
+ return annotations;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java
new file mode 100644
index 0000000..0c2ef29
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java
@@ -0,0 +1,298 @@
+/*
+ * 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.AbstractClientPayload;
+import org.apache.olingo.commons.api.domain.ClientAnnotation;
+import org.apache.olingo.commons.api.domain.ClientEntity;
+import org.apache.olingo.commons.api.domain.ClientLink;
+import org.apache.olingo.commons.api.domain.ClientOperation;
+import org.apache.olingo.commons.api.domain.ClientProperty;
+import org.apache.olingo.commons.api.domain.ClientSingleton;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+public class ClientEntityImpl extends AbstractClientPayload implements ClientEntity, ClientSingleton {
+
+ /**
+ * Entity id.
+ */
+ private URI id;
+ /**
+ * 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 URI mediaContentSource;
+ /**
+ * Media ETag.
+ */
+ private String mediaETag;
+ /**
+ * Edit link.
+ */
+ private URI editLink;
+
+ private final List<ClientProperty> properties = new ArrayList<ClientProperty>();
+
+ private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
+
+ private final FullQualifiedName typeName;
+ /**
+ * Navigation links (might contain in-line entities or entity sets).
+ */
+ private final List<ClientLink> navigationLinks = new ArrayList<ClientLink>();
+ /**
+ * Association links.
+ */
+ private final List<ClientLink> associationLinks = new ArrayList<ClientLink>();
+ /**
+ * Media edit links.
+ */
+ private final List<ClientLink> mediaEditLinks = new ArrayList<ClientLink>();
+ /**
+ * Operations (legacy, functions, actions).
+ */
+ private final List<ClientOperation> operations = new ArrayList<ClientOperation>();
+
+ public ClientEntityImpl(final FullQualifiedName typeName) {
+ super(typeName == null ? null : typeName.toString());
+ this.typeName = typeName;
+ }
+
+ @Override
+ public FullQualifiedName getTypeName() {
+ return typeName;
+ }
+
+ @Override
+ public String getETag() {
+ return eTag;
+ }
+
+ @Override
+ public void setETag(final String eTag) {
+ this.eTag = eTag;
+ }
+
+ @Override
+ public ClientOperation getOperation(final String title) {
+ ClientOperation result = null;
+ for (ClientOperation operation : operations) {
+ if (title.equals(operation.getTitle())) {
+ result = operation;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets operations.
+ *
+ * @return operations.
+ */
+ @Override
+ public List<ClientOperation> getOperations() {
+ return operations;
+ }
+
+
+ @Override
+ public ClientProperty getProperty(final String name) {
+ ClientProperty result = null;
+
+ if (StringUtils.isNotBlank(name)) {
+ for (ClientProperty property : getProperties()) {
+ if (name.equals(property.getName())) {
+ result = property;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean addLink(final ClientLink 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 = mediaEditLinks.contains(link) ? false : mediaEditLinks.add(link);
+ break;
+
+ default:
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean removeLink(final ClientLink link) {
+ return associationLinks.remove(link) || navigationLinks.remove(link);
+ }
+
+ private ClientLink getLink(final List<ClientLink> links, final String name) {
+ ClientLink result = null;
+ for (ClientLink link : links) {
+ if (name.equals(link.getName())) {
+ result = link;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public ClientLink getNavigationLink(final String name) {
+ return getLink(navigationLinks, name);
+ }
+
+ @Override
+ public List<ClientLink> getNavigationLinks() {
+ return navigationLinks;
+ }
+
+ @Override
+ public ClientLink getAssociationLink(final String name) {
+ return getLink(associationLinks, name);
+ }
+
+ @Override
+ public List<ClientLink> getAssociationLinks() {
+ return associationLinks;
+ }
+
+ @Override
+ public ClientLink getMediaEditLink(final String name) {
+ return getLink(mediaEditLinks, name);
+ }
+
+ @Override
+ public List<ClientLink> getMediaEditLinks() {
+ return mediaEditLinks;
+ }
+
+ @Override
+ public URI getEditLink() {
+ return editLink;
+ }
+
+ @Override
+ public void setEditLink(final URI editLink) {
+ this.editLink = editLink;
+ }
+
+ @Override
+ public URI getLink() {
+ return super.getLink() == null ? getEditLink() : super.getLink();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return super.getLink() != null;
+ }
+
+ @Override
+ public boolean isMediaEntity() {
+ return mediaEntity;
+ }
+
+ @Override
+ public void setMediaEntity(final boolean isMediaEntity) {
+ mediaEntity = isMediaEntity;
+ }
+
+ @Override
+ public String getMediaContentType() {
+ return mediaContentType;
+ }
+
+ @Override
+ public void setMediaContentType(final String mediaContentType) {
+ this.mediaContentType = mediaContentType;
+ }
+
+ @Override
+ public URI getMediaContentSource() {
+ return mediaContentSource;
+ }
+
+ @Override
+ public void setMediaContentSource(final URI mediaContentSource) {
+ this.mediaContentSource = mediaContentSource;
+ }
+
+ @Override
+ public String getMediaETag() {
+ return mediaETag;
+ }
+
+ @Override
+ public void setMediaETag(final String eTag) {
+ mediaETag = eTag;
+ }
+
+ @Override
+ public URI getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(final URI id) {
+ this.id = id;
+ }
+
+ @Override
+ public List<ClientProperty> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public List<ClientAnnotation> getAnnotations() {
+ return annotations;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java
new file mode 100644
index 0000000..4e4d79b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java
@@ -0,0 +1,65 @@
+/*
+ * 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.olingo.commons.api.domain.ClientAnnotation;
+import org.apache.olingo.commons.api.domain.ClientEntity;
+import org.apache.olingo.commons.api.domain.ClientEntitySet;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClientEntitySetImpl extends AbstractClientEntitySet implements ClientEntitySet {
+
+ private URI deltaLink;
+
+ private final List<ClientEntity> entities = new ArrayList<ClientEntity>();
+
+ private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
+
+ public ClientEntitySetImpl() {
+ super();
+ }
+
+ public ClientEntitySetImpl(final URI next) {
+ super(next);
+ }
+
+ @Override
+ public List<ClientEntity> getEntities() {
+ return entities;
+ }
+
+ @Override
+ public URI getDeltaLink() {
+ return deltaLink;
+ }
+
+ @Override
+ public void setDeltaLink(final URI deltaLink) {
+ this.deltaLink = deltaLink;
+ }
+
+ @Override
+ public List<ClientAnnotation> getAnnotations() {
+ return annotations;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java
new file mode 100644
index 0000000..12634d4
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java
@@ -0,0 +1,59 @@
+/*
+ * 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.olingo.commons.api.domain.AbstractClientValue;
+import org.apache.olingo.commons.api.domain.ClientEnumValue;
+
+public class ClientEnumValueImpl extends AbstractClientValue implements ClientEnumValue {
+
+ private final String value;
+
+ public ClientEnumValueImpl(final String typeName, final String value) {
+ super(typeName);
+ this.value = value;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean isEnum() {
+ return true;
+ }
+
+ @Override
+ public ClientEnumValue asEnum() {
+ return this;
+ }
+
+ @Override
+ public boolean isComplex() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return getTypeName() + "'" + getValue() + "'";
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java
new file mode 100644
index 0000000..ed4692f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java
@@ -0,0 +1,155 @@
+/*
+ * 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.ClientCollectionValue;
+import org.apache.olingo.commons.api.domain.ClientComplexValue;
+import org.apache.olingo.commons.api.domain.ClientDelta;
+import org.apache.olingo.commons.api.domain.ClientEntity;
+import org.apache.olingo.commons.api.domain.ClientEntitySet;
+import org.apache.olingo.commons.api.domain.ClientEnumValue;
+import org.apache.olingo.commons.api.domain.ClientInlineEntity;
+import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ClientLink;
+import org.apache.olingo.commons.api.domain.ClientLinkType;
+import org.apache.olingo.commons.api.domain.ClientObjectFactory;
+import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ClientProperty;
+import org.apache.olingo.commons.api.domain.ClientSingleton;
+import org.apache.olingo.commons.api.domain.ClientValue;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+
+public class ClientObjectFactoryImpl implements ClientObjectFactory {
+
+ @Override
+ public ClientInlineEntitySet newDeepInsertEntitySet(final String name, final ClientEntitySet entitySet) {
+ return new ClientInlineEntitySet(null, ClientLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
+ }
+
+ @Override
+ public ClientInlineEntity newDeepInsertEntity(final String name, final ClientEntity entity) {
+ return new ClientInlineEntity(null, ClientLinkType.ENTITY_NAVIGATION, name, entity);
+ }
+
+ @Override
+ public ClientEntitySet newEntitySet() {
+ return new ClientEntitySetImpl();
+ }
+
+ @Override
+ public ClientEntitySet newEntitySet(final URI next) {
+ return new ClientEntitySetImpl(next);
+ }
+
+ @Override
+ public ClientEntity newEntity(final FullQualifiedName typeName) {
+ return new ClientEntityImpl(typeName);
+ }
+
+ @Override
+ public ClientEntity newEntity(final FullQualifiedName typeName, final URI link) {
+ final ClientEntityImpl result = new ClientEntityImpl(typeName);
+ result.setLink(link);
+ return result;
+ }
+
+ @Override
+ public ClientSingleton newSingleton(final FullQualifiedName typeName) {
+ return new ClientEntityImpl(typeName);
+ }
+
+ @Override
+ public ClientLink newEntityNavigationLink(final String name, final URI link) {
+ return new ClientLink.Builder().setURI(link).
+ setType(ClientLinkType.ENTITY_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ClientLink newEntitySetNavigationLink(final String name, final URI link) {
+ return new ClientLink.Builder().setURI(link).
+ setType(ClientLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
+ }
+
+ @Override
+ public ClientLink newAssociationLink(final String name, final URI link) {
+ return new ClientLink.Builder().setURI(link).
+ setType(ClientLinkType.ASSOCIATION).setTitle(name).build();
+ }
+
+ @Override
+ public ClientLink newMediaEditLink(final String name, final URI link) {
+ return new ClientLink.Builder().setURI(link).
+ setType(ClientLinkType.MEDIA_EDIT).setTitle(name).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue.Builder newPrimitiveValueBuilder() {
+ return new ClientPrimitiveValueImpl.BuilderImpl();
+ }
+
+ @Override
+ public ClientEnumValue newEnumValue(final String typeName, final String value) {
+ return new ClientEnumValueImpl(typeName, value);
+ }
+
+ @Override
+ public ClientComplexValue newComplexValue(final String typeName) {
+ return new ClientComplexValueImpl(typeName);
+ }
+
+ @Override
+ public ClientCollectionValue<ClientValue> newCollectionValue(final String typeName) {
+ return new ClientCollectionValueImpl<ClientValue>(typeName);
+ }
+
+ @Override
+ public ClientProperty newPrimitiveProperty(final String name, final ClientPrimitiveValue value) {
+ return new ClientPropertyImpl(name, value);
+ }
+
+ @Override
+ public ClientProperty newComplexProperty(final String name, final ClientComplexValue value) {
+
+ return new ClientPropertyImpl(name, value);
+ }
+
+ @Override
+ public ClientProperty newCollectionProperty(final String name,
+ final ClientCollectionValue<? extends ClientValue> value) {
+
+ return new ClientPropertyImpl(name, value);
+ }
+
+ @Override
+ public ClientProperty newEnumProperty(final String name, final ClientEnumValue value) {
+ return new ClientPropertyImpl(name, value);
+ }
+
+ @Override
+ public ClientDelta newDelta() {
+ return new ClientDeltaImpl();
+ }
+
+ @Override
+ public ClientDelta newDelta(final URI next) {
+ return new ClientDeltaImpl(next);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java
new file mode 100644
index 0000000..0f6ad2b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java
@@ -0,0 +1,222 @@
+/*
+ * 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.UUID;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.domain.AbstractClientValue;
+import org.apache.olingo.commons.api.domain.ClientEnumValue;
+import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ClientValue;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+public class ClientPrimitiveValueImpl extends AbstractClientValue implements ClientValue, ClientPrimitiveValue {
+
+ public static class BuilderImpl implements Builder {
+
+ private final ClientPrimitiveValueImpl instance;
+
+ public BuilderImpl() {
+ instance = new ClientPrimitiveValueImpl();
+ }
+
+ @Override
+ public BuilderImpl setType(final EdmType type) {
+ EdmPrimitiveTypeKind primitiveTypeKind = null;
+ if (type != null) {
+ if (type.getKind() != EdmTypeKind.PRIMITIVE) {
+ throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type));
+ }
+ primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName());
+ }
+ return setType(primitiveTypeKind);
+ }
+
+ @Override
+ public BuilderImpl setType(final EdmPrimitiveTypeKind type) {
+ if (type == EdmPrimitiveTypeKind.Stream) {
+ throw new IllegalArgumentException(String.format(
+ "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
+ }
+ if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
+ throw new IllegalArgumentException(
+ type + "is not an instantiable type. "
+ + "An entity can declare a property to be of type Geometry. "
+ + "An instance of an entity MUST NOT have a value of type Geometry. "
+ + "Each value MUST be of some subtype.");
+ }
+
+ instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type;
+ instance.type = EdmPrimitiveTypeFactory.getInstance(instance.typeKind);
+
+ return this;
+ }
+
+ @Override
+ public BuilderImpl setValue(final Object value) {
+ instance.value = value;
+ return this;
+ }
+
+ @Override
+ public ClientPrimitiveValue build() {
+ if (instance.type == null) {
+ setType(EdmPrimitiveTypeKind.String);
+ }
+ return instance;
+ }
+
+ @Override
+ public ClientPrimitiveValue buildBoolean(final Boolean value) {
+ return setType(EdmPrimitiveTypeKind.Boolean).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildInt16(final Short value) {
+ return setType(EdmPrimitiveTypeKind.Int16).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildInt32(final Integer value) {
+ return setType(EdmPrimitiveTypeKind.Int32).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildInt64(final Long value) {
+ return setType(EdmPrimitiveTypeKind.Int64).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildSingle(final Float value) {
+ return setType(EdmPrimitiveTypeKind.Single).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildDouble(final Double value) {
+ return setType(EdmPrimitiveTypeKind.Double).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildString(final String value) {
+ return setType(EdmPrimitiveTypeKind.String).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildGuid(final UUID value) {
+ return setType(EdmPrimitiveTypeKind.Guid).setValue(value).build();
+ }
+
+ @Override
+ public ClientPrimitiveValue buildBinary(final byte[] value) {
+ return setType(EdmPrimitiveTypeKind.Binary).setValue(value).build();
+ }
+
+ }
+
+ /**
+ * Type kind.
+ */
+ private EdmPrimitiveTypeKind typeKind;
+
+ /**
+ * Type.
+ */
+ private EdmPrimitiveType type;
+
+ /**
+ * Actual value.
+ */
+ private Object value;
+
+ protected ClientPrimitiveValueImpl() {
+ super(null);
+ }
+
+ @Override
+ public String getTypeName() {
+ return typeKind.getFullQualifiedName().toString();
+ }
+
+ @Override
+ public EdmPrimitiveTypeKind getTypeKind() {
+ return typeKind;
+ }
+
+ @Override
+ public EdmPrimitiveType getType() {
+ return type;
+ }
+
+ @Override
+ public Object toValue() {
+ return value;
+ }
+
+ @Override
+ public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
+ if (value == null) {
+ return null;
+ } else if (typeKind.isGeospatial()) {
+ return reference.cast(value);
+ } else {
+ // TODO: set facets
+ return type.valueOfString(type.valueToString(value,
+ null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null),
+ null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
+ }
+ }
+
+ @Override
+ public String toString() {
+ if (value == null) {
+ return "";
+ } else if (typeKind.isGeospatial()) {
+ return value.toString();
+ } else {
+ try {
+ // TODO: set facets
+ return type.valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+ } catch (EdmPrimitiveTypeException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+
+ @Override
+ public boolean isEnum() {
+ return false;
+ }
+
+ @Override
+ public ClientEnumValue asEnum() {
+ return null;
+ }
+
+ @Override
+ public boolean isComplex() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java
new file mode 100644
index 0000000..e53c94b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java
@@ -0,0 +1,163 @@
+/*
+ * 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.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.olingo.commons.api.domain.ClientAnnotatable;
+import org.apache.olingo.commons.api.domain.ClientAnnotation;
+import org.apache.olingo.commons.api.domain.ClientCollectionValue;
+import org.apache.olingo.commons.api.domain.ClientComplexValue;
+import org.apache.olingo.commons.api.domain.ClientEnumValue;
+import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ClientProperty;
+import org.apache.olingo.commons.api.domain.ClientValuable;
+import org.apache.olingo.commons.api.domain.ClientValue;
+
+public class ClientPropertyImpl implements ClientProperty, ClientAnnotatable, ClientValuable {
+
+
+ private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
+ private final String name;
+ private final ClientValue value;
+ private final ClientValuable valuable;
+
+ public ClientPropertyImpl(final String name, final ClientValue value) {
+ this.name = name;
+ this.value = value;
+ this.valuable = new ClientValuableImpl(value);
+ }
+
+ /**
+ * Returns property name.
+ *
+ * @return property name.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns property value.
+ *
+ * @return property value.
+ */
+ @Override
+ public ClientValue getValue() {
+ return value;
+ }
+
+ /**
+ * Checks if has null value.
+ *
+ * @return 'TRUE' if has null value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasNullValue() {
+ return value == null || value.isPrimitive() && value.asPrimitive().toValue() == null;
+ }
+
+ /**
+ * Checks if has primitive value.
+ *
+ * @return 'TRUE' if has primitive value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasPrimitiveValue() {
+ return !hasNullValue() && value.isPrimitive();
+ }
+
+ /**
+ * Gets primitive value.
+ *
+ * @return primitive value if exists; null otherwise.
+ */
+ @Override
+ public ClientPrimitiveValue getPrimitiveValue() {
+ return hasPrimitiveValue() ? value.asPrimitive() : null;
+ }
+
+ /**
+ * Checks if has complex value.
+ *
+ * @return 'TRUE' if has complex value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasComplexValue() {
+ return !hasNullValue() && value.isComplex();
+ }
+
+ /**
+ * Checks if has collection value.
+ *
+ * @return 'TRUE' if has collection value; 'FALSE' otherwise.
+ */
+ @Override
+ public boolean hasCollectionValue() {
+ return !hasNullValue() && value.isCollection();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public boolean hasEnumValue() {
+ return valuable.hasEnumValue();
+ }
+
+ @Override
+ public ClientEnumValue getEnumValue() {
+ return valuable.getEnumValue();
+ }
+
+ @Override
+ public ClientComplexValue getComplexValue() {
+ return valuable.getComplexValue();
+ }
+
+ @Override
+ public ClientCollectionValue<ClientValue> getCollectionValue() {
+ return valuable.getCollectionValue();
+ }
+
+ @Override
+ public List<ClientAnnotation> getAnnotations() {
+ return annotations;
+ }
+
+ @Override
+ public String toString() {
+ return "ODataPropertyImpl{"
+ + "name=" + getName()
+ + ",valuable=" + valuable
+ + ", annotations=" + annotations
+ + '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java
new file mode 100644
index 0000000..561d3df
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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.ClientCollectionValue;
+import org.apache.olingo.commons.api.domain.ClientComplexValue;
+import org.apache.olingo.commons.api.domain.ClientEnumValue;
+import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
+import org.apache.olingo.commons.api.domain.ClientValuable;
+import org.apache.olingo.commons.api.domain.ClientValue;
+
+public class ClientValuableImpl implements ClientValuable {
+
+ private final ClientValue value;
+
+ public ClientValuableImpl(final ClientValue value) {
+ this.value = value;
+ }
+
+ @Override
+ public ClientValue getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean hasNullValue() {
+ return value == null;
+ }
+
+ @Override
+ public boolean hasPrimitiveValue() {
+ return !hasNullValue() && value.isPrimitive();
+ }
+
+ @Override
+ public ClientPrimitiveValue getPrimitiveValue() {
+ return hasPrimitiveValue() ? value.asPrimitive() : null;
+ }
+
+ @Override
+ public boolean hasCollectionValue() {
+ return !hasNullValue() && value.isCollection();
+ }
+
+ @Override
+ public ClientCollectionValue<ClientValue> getCollectionValue() {
+ return hasCollectionValue()
+ ? getValue().<ClientValue> asCollection()
+ : null;
+ }
+
+ @Override
+ public boolean hasComplexValue() {
+ return !hasNullValue() && value.isComplex();
+ }
+
+ @Override
+ public ClientComplexValue getComplexValue() {
+ return hasComplexValue()
+ ? getValue().asComplex()
+ : null;
+ }
+
+ @Override
+ public boolean hasEnumValue() {
+ return !hasNullValue() && getValue().isEnum();
+ }
+
+ @Override
+ public ClientEnumValue getEnumValue() {
+ return hasEnumValue()
+ ? getValue().asEnum()
+ : null;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
deleted file mode 100644
index 1ca150b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataAnnotationImpl.java
+++ /dev/null
@@ -1,102 +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.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataValuable;
-import org.apache.olingo.commons.api.domain.ODataValue;
-
-public class ODataAnnotationImpl implements ODataAnnotation {
-
- private final String term;
-
- private final ODataValuable valuable;
-
- public ODataAnnotationImpl(final String term, final ODataValue value) {
- this.term = term;
- valuable = new ODataValuableImpl(value);
- }
-
- @Override
- public String getTerm() {
- return term;
- }
-
- @Override
- public ODataValue getValue() {
- return valuable.getValue();
- }
-
- @Override
- public boolean hasNullValue() {
- return valuable.hasNullValue();
- }
-
- @Override
- public boolean hasPrimitiveValue() {
- return valuable.hasPrimitiveValue();
- }
-
- @Override
- public ODataPrimitiveValue getPrimitiveValue() {
- return valuable.getPrimitiveValue();
- }
-
- @Override
- public boolean hasCollectionValue() {
- return valuable.hasCollectionValue();
- }
-
- @Override
- public ODataCollectionValue<ODataValue> getCollectionValue() {
- return valuable.getCollectionValue();
- }
-
- @Override
- public boolean hasComplexValue() {
- return valuable.hasComplexValue();
- }
-
- @Override
- public ODataComplexValue getComplexValue() {
- return valuable.getComplexValue();
- }
-
- @Override
- public boolean hasEnumValue() {
- return valuable.hasEnumValue();
- }
-
- @Override
- public ODataEnumValue getEnumValue() {
- return valuable.getEnumValue();
- }
-
- @Override
- public String toString() {
- return "ODataPropertyImpl{"
- + "term=" + term
- + ",valuable=" + valuable
- + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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
deleted file mode 100644
index c608313..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataCollectionValueImpl.java
+++ /dev/null
@@ -1,124 +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.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataValue;
-
-public class ODataCollectionValueImpl<OV extends ODataValue> extends AbstractODataValue
- implements ODataCollectionValue<OV>, ODataValue {
-
- /**
- * Constructor.
- *
- * @param typeName type name.
- */
- public ODataCollectionValueImpl(final String typeName) {
- super(typeName == null || typeName.startsWith("Collection(") ? typeName : "Collection(" + typeName + ")");
- }
-
- @Override
- public boolean isEnum() {
- return false;
- }
-
- @Override
- public ODataEnumValue asEnum() {
- return null;
- }
-
- @Override
- public boolean isComplex() {
- return false;
- }
-
- @Override
- public Collection<Object> asJavaCollection() {
- final List<Object> result = new ArrayList<Object>();
- for (ODataValue value : values) {
- if (value.isPrimitive()) {
- result.add(value.asPrimitive().toValue());
- } else if (value.isComplex()) {
- result.add(value.asComplex().asJavaMap());
- } else if (value.isCollection()) {
- result.add(value.asCollection().asJavaCollection());
- } else if (value.isEnum()) {
- result.add(value.asEnum().toString());
- }
- }
-
- return result;
- }
-
- /**
- * Values.
- */
- protected final List<OV> values = new ArrayList<OV>();
-
- /**
- * Adds a value to the collection.
- *
- * @param value value to be added.
- */
- @Override
- @SuppressWarnings("unchecked")
- public ODataCollectionValue<OV> add(final ODataValue value) {
- values.add((OV) value);
- return this;
- }
-
- /**
- * Value iterator.
- *
- * @return value iterator.
- */
- @Override
- public Iterator<OV> 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/c37d4da5/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
deleted file mode 100644
index efb5744..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
+++ /dev/null
@@ -1,204 +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.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataProperty;
-
-public class ODataComplexValueImpl extends AbstractODataValue implements ODataComplexValue {
-
- /**
- * Navigation links (might contain in-line entities or entity sets).
- */
- private final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
-
- /**
- * Association links.
- */
- private final List<ODataLink> associationLinks = new ArrayList<ODataLink>();
-
- private final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>();
-
- /**
- * 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);
- }
-
- @Override
- public boolean isEnum() {
- return false;
- }
-
- @Override
- public ODataEnumValue asEnum() {
- return null;
- }
-
- @Override
- public boolean isComplex() {
- return true;
- }
-
- @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:
- throw new IllegalArgumentException("Complex values cannot have media links!");
-
- default:
- }
-
- return result;
- }
-
- @Override
- public boolean removeLink(final ODataLink link) {
- return associationLinks.remove(link) || navigationLinks.remove(link);
- }
-
- private ODataLink getLink(final List<ODataLink> links, final String name) {
- ODataLink result = null;
- for (ODataLink link : links) {
- if (name.equals(link.getName())) {
- result = link;
- break;
- }
- }
-
- return result;
- }
-
- @Override
- public ODataLink getNavigationLink(final String name) {
- return getLink(navigationLinks, name);
- }
-
- @Override
- public List<ODataLink> getNavigationLinks() {
- return navigationLinks;
- }
-
- @Override
- public ODataLink getAssociationLink(final String name) {
- return getLink(associationLinks, name);
- }
-
- @Override
- public List<ODataLink> getAssociationLinks() {
- return associationLinks;
- }
-
- @Override
- public Map<String, Object> asJavaMap() {
- final Map<String, Object> result = new LinkedHashMap<String, Object>();
- for (Map.Entry<String, ODataProperty> entry : fields.entrySet()) {
- Object value = null;
- if (entry.getValue().hasPrimitiveValue()) {
- value = entry.getValue().getPrimitiveValue().toValue();
- } else if (entry.getValue().hasComplexValue()) {
- value = entry.getValue().getComplexValue().asJavaMap();
- } else if (entry.getValue().hasCollectionValue()) {
- value = entry.getValue().getCollectionValue().asJavaCollection();
- } else if (entry.getValue().hasEnumValue()) {
- value = entry.getValue().getEnumValue().toString();
- }
-
- result.put(entry.getKey(), value);
- }
-
- return result;
- }
-
- @Override
- public List<ODataAnnotation> getAnnotations() {
- return annotations;
- }
-
- /**
- * Adds field to the complex type.
- *
- * @param field field to be added.
- */
- @Override
- public ODataComplexValue add(final ODataProperty field) {
- fields.put(field.getName(), field);
- return this;
- }
-
- /**
- * 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/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeletedEntityImpl.java
deleted file mode 100644
index 4021996..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeletedEntityImpl.java
+++ /dev/null
@@ -1,54 +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.olingo.commons.api.domain.ODataDeletedEntity;
-import org.apache.olingo.commons.api.domain.ODataItem;
-
-import java.net.URI;
-
-public class ODataDeletedEntityImpl extends ODataItem implements ODataDeletedEntity {
-
- private URI id;
-
- private Reason reason;
-
- public ODataDeletedEntityImpl() {
- super(null);
- }
-
- @Override
- public URI getId() {
- return id;
- }
-
- public void setId(final URI id) {
- this.id = id;
- }
-
- @Override
- public Reason getReason() {
- return reason;
- }
-
- public void setReason(final Reason reason) {
- this.reason = reason;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaImpl.java
deleted file mode 100644
index f8d6fdf..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaImpl.java
+++ /dev/null
@@ -1,60 +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.olingo.commons.api.domain.ODataDeletedEntity;
-import org.apache.olingo.commons.api.domain.ODataDelta;
-import org.apache.olingo.commons.api.domain.ODataDeltaLink;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ODataDeltaImpl extends ODataEntitySetImpl implements ODataDelta {
-
- private final List<ODataDeletedEntity> deletedEntities = new ArrayList<ODataDeletedEntity>();
-
- private final List<ODataDeltaLink> addedLinks = new ArrayList<ODataDeltaLink>();
-
- private final List<ODataDeltaLink> deletedLinks = new ArrayList<ODataDeltaLink>();
-
- public ODataDeltaImpl() {
- super();
- }
-
- public ODataDeltaImpl(final URI next) {
- super(next);
- }
-
- @Override
- public List<ODataDeletedEntity> getDeletedEntities() {
- return deletedEntities;
- }
-
- @Override
- public List<ODataDeltaLink> getAddedLinks() {
- return addedLinks;
- }
-
- @Override
- public List<ODataDeltaLink> getDeletedLinks() {
- return deletedLinks;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaLinkImpl.java
deleted file mode 100644
index 5a39382..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataDeltaLinkImpl.java
+++ /dev/null
@@ -1,78 +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.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataDeltaLink;
-import org.apache.olingo.commons.api.domain.ODataItem;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ODataDeltaLinkImpl extends ODataItem implements ODataDeltaLink {
-
- private URI source;
-
- private String relationship;
-
- private URI target;
-
- private final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>();
-
- public ODataDeltaLinkImpl() {
- super(null);
- }
-
- @Override
- public URI getSource() {
- return source;
- }
-
- @Override
- public void setSource(final URI source) {
- this.source = source;
- }
-
- @Override
- public String getRelationship() {
- return relationship;
- }
-
- @Override
- public void setRelationship(final String relationship) {
- this.relationship = relationship;
- }
-
- @Override
- public URI getTarget() {
- return target;
- }
-
- @Override
- public void setTarget(final URI target) {
- this.target = target;
- }
-
- @Override
- public List<ODataAnnotation> getAnnotations() {
- return annotations;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 f3bbe0c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
+++ /dev/null
@@ -1,298 +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.ODataAnnotation;
-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;
-import org.apache.olingo.commons.api.domain.ODataSingleton;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-
-public class ODataEntityImpl extends AbstractODataPayload implements ODataEntity, ODataSingleton {
-
- /**
- * Entity id.
- */
- private URI id;
- /**
- * 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 URI mediaContentSource;
- /**
- * Media ETag.
- */
- private String mediaETag;
- /**
- * Edit link.
- */
- private URI editLink;
-
- private final List<ODataProperty> properties = new ArrayList<ODataProperty>();
-
- private final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>();
-
- private final FullQualifiedName typeName;
- /**
- * Navigation links (might contain in-line entities or entity sets).
- */
- 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> mediaEditLinks = new ArrayList<ODataLink>();
- /**
- * Operations (legacy, functions, actions).
- */
- private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
-
- public ODataEntityImpl(final FullQualifiedName typeName) {
- super(typeName == null ? null : typeName.toString());
- this.typeName = typeName;
- }
-
- @Override
- public FullQualifiedName getTypeName() {
- return typeName;
- }
-
- @Override
- public String getETag() {
- return eTag;
- }
-
- @Override
- public void setETag(final String eTag) {
- this.eTag = eTag;
- }
-
- @Override
- public ODataOperation getOperation(final String title) {
- ODataOperation result = null;
- for (ODataOperation operation : operations) {
- if (title.equals(operation.getTitle())) {
- result = operation;
- break;
- }
- }
-
- return result;
- }
-
- /**
- * Gets operations.
- *
- * @return operations.
- */
- @Override
- public List<ODataOperation> getOperations() {
- return operations;
- }
-
-
- @Override
- public ODataProperty getProperty(final String name) {
- ODataProperty result = null;
-
- if (StringUtils.isNotBlank(name)) {
- for (ODataProperty property : getProperties()) {
- if (name.equals(property.getName())) {
- result = property;
- break;
- }
- }
- }
-
- return result;
- }
-
- @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 = mediaEditLinks.contains(link) ? false : mediaEditLinks.add(link);
- break;
-
- default:
- }
-
- return result;
- }
-
- @Override
- public boolean removeLink(final ODataLink link) {
- return associationLinks.remove(link) || navigationLinks.remove(link);
- }
-
- private ODataLink getLink(final List<ODataLink> links, final String name) {
- ODataLink result = null;
- for (ODataLink link : links) {
- if (name.equals(link.getName())) {
- result = link;
- break;
- }
- }
-
- return result;
- }
-
- @Override
- public ODataLink getNavigationLink(final String name) {
- return getLink(navigationLinks, name);
- }
-
- @Override
- public List<ODataLink> getNavigationLinks() {
- return navigationLinks;
- }
-
- @Override
- public ODataLink getAssociationLink(final String name) {
- return getLink(associationLinks, name);
- }
-
- @Override
- public List<ODataLink> getAssociationLinks() {
- return associationLinks;
- }
-
- @Override
- public ODataLink getMediaEditLink(final String name) {
- return getLink(mediaEditLinks, name);
- }
-
- @Override
- public List<ODataLink> getMediaEditLinks() {
- return mediaEditLinks;
- }
-
- @Override
- public URI getEditLink() {
- return editLink;
- }
-
- @Override
- public void setEditLink(final URI editLink) {
- this.editLink = editLink;
- }
-
- @Override
- public URI getLink() {
- return super.getLink() == null ? getEditLink() : super.getLink();
- }
-
- @Override
- public boolean isReadOnly() {
- return super.getLink() != null;
- }
-
- @Override
- public boolean isMediaEntity() {
- return mediaEntity;
- }
-
- @Override
- public void setMediaEntity(final boolean isMediaEntity) {
- mediaEntity = isMediaEntity;
- }
-
- @Override
- public String getMediaContentType() {
- return mediaContentType;
- }
-
- @Override
- public void setMediaContentType(final String mediaContentType) {
- this.mediaContentType = mediaContentType;
- }
-
- @Override
- public URI getMediaContentSource() {
- return mediaContentSource;
- }
-
- @Override
- public void setMediaContentSource(final URI mediaContentSource) {
- this.mediaContentSource = mediaContentSource;
- }
-
- @Override
- public String getMediaETag() {
- return mediaETag;
- }
-
- @Override
- public void setMediaETag(final String eTag) {
- mediaETag = eTag;
- }
-
- @Override
- public URI getId() {
- return id;
- }
-
- @Override
- public void setId(final URI id) {
- this.id = id;
- }
-
- @Override
- public List<ODataProperty> getProperties() {
- return properties;
- }
-
- @Override
- public List<ODataAnnotation> getAnnotations() {
- return annotations;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 b6853c1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntitySetImpl.java
+++ /dev/null
@@ -1,65 +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.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataEntitySet;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ODataEntitySetImpl extends AbstractODataEntitySet implements ODataEntitySet {
-
- private URI deltaLink;
-
- private final List<ODataEntity> entities = new ArrayList<ODataEntity>();
-
- private final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>();
-
- public ODataEntitySetImpl() {
- super();
- }
-
- public ODataEntitySetImpl(final URI next) {
- super(next);
- }
-
- @Override
- public List<ODataEntity> getEntities() {
- return entities;
- }
-
- @Override
- public URI getDeltaLink() {
- return deltaLink;
- }
-
- @Override
- public void setDeltaLink(final URI deltaLink) {
- this.deltaLink = deltaLink;
- }
-
- @Override
- public List<ODataAnnotation> getAnnotations() {
- return annotations;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
deleted file mode 100644
index 9ef7ed1..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEnumValueImpl.java
+++ /dev/null
@@ -1,59 +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.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-
-public class ODataEnumValueImpl extends AbstractODataValue implements ODataEnumValue {
-
- private final String value;
-
- public ODataEnumValueImpl(final String typeName, final String value) {
- super(typeName);
- this.value = value;
- }
-
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public boolean isEnum() {
- return true;
- }
-
- @Override
- public ODataEnumValue asEnum() {
- return this;
- }
-
- @Override
- public boolean isComplex() {
- return false;
- }
-
- @Override
- public String toString() {
- return getTypeName() + "'" + getValue() + "'";
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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 eb82364..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataObjectFactoryImpl.java
+++ /dev/null
@@ -1,155 +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.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataDelta;
-import org.apache.olingo.commons.api.domain.ODataEntity;
-import org.apache.olingo.commons.api.domain.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.ODataObjectFactory;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataProperty;
-import org.apache.olingo.commons.api.domain.ODataSingleton;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-
-public class ODataObjectFactoryImpl implements ODataObjectFactory {
-
- @Override
- public ODataInlineEntitySet newDeepInsertEntitySet(final String name, final ODataEntitySet entitySet) {
- return new ODataInlineEntitySet(null, ODataLinkType.ENTITY_SET_NAVIGATION, name, entitySet);
- }
-
- @Override
- public ODataInlineEntity newDeepInsertEntity(final String name, final ODataEntity entity) {
- return new ODataInlineEntity(null, ODataLinkType.ENTITY_NAVIGATION, name, entity);
- }
-
- @Override
- public ODataEntitySet newEntitySet() {
- return new ODataEntitySetImpl();
- }
-
- @Override
- public ODataEntitySet newEntitySet(final URI next) {
- return new ODataEntitySetImpl(next);
- }
-
- @Override
- public ODataEntity newEntity(final FullQualifiedName typeName) {
- return new ODataEntityImpl(typeName);
- }
-
- @Override
- public ODataEntity newEntity(final FullQualifiedName typeName, final URI link) {
- final ODataEntityImpl result = new ODataEntityImpl(typeName);
- result.setLink(link);
- return result;
- }
-
- @Override
- public ODataSingleton newSingleton(final FullQualifiedName typeName) {
- return new ODataEntityImpl(typeName);
- }
-
- @Override
- public ODataLink newEntityNavigationLink(final String name, final URI link) {
- return new ODataLink.Builder().setURI(link).
- setType(ODataLinkType.ENTITY_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newEntitySetNavigationLink(final String name, final URI link) {
- return new ODataLink.Builder().setURI(link).
- setType(ODataLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newAssociationLink(final String name, final URI link) {
- return new ODataLink.Builder().setURI(link).
- setType(ODataLinkType.ASSOCIATION).setTitle(name).build();
- }
-
- @Override
- public ODataLink newMediaEditLink(final String name, final URI link) {
- return new ODataLink.Builder().setURI(link).
- setType(ODataLinkType.MEDIA_EDIT).setTitle(name).build();
- }
-
- @Override
- public ODataPrimitiveValue.Builder newPrimitiveValueBuilder() {
- return new ODataPrimitiveValueImpl.BuilderImpl();
- }
-
- @Override
- public ODataEnumValue newEnumValue(final String typeName, final String value) {
- return new ODataEnumValueImpl(typeName, value);
- }
-
- @Override
- public ODataComplexValue newComplexValue(final String typeName) {
- return new ODataComplexValueImpl(typeName);
- }
-
- @Override
- public ODataCollectionValue<ODataValue> newCollectionValue(final String typeName) {
- return new ODataCollectionValueImpl<ODataValue>(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<? extends org.apache.olingo.commons.api.domain.ODataValue> value) {
-
- return new ODataPropertyImpl(name, value);
- }
-
- @Override
- public ODataProperty newEnumProperty(final String name, final ODataEnumValue value) {
- return new ODataPropertyImpl(name, value);
- }
-
- @Override
- public ODataDelta newDelta() {
- return new ODataDeltaImpl();
- }
-
- @Override
- public ODataDelta newDelta(final URI next) {
- return new ODataDeltaImpl(next);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/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
deleted file mode 100644
index 64ef5db..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
+++ /dev/null
@@ -1,222 +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.util.UUID;
-
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.domain.AbstractODataValue;
-import org.apache.olingo.commons.api.domain.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-public class ODataPrimitiveValueImpl extends AbstractODataValue implements ODataValue, ODataPrimitiveValue {
-
- public static class BuilderImpl implements Builder {
-
- private final ODataPrimitiveValueImpl instance;
-
- public BuilderImpl() {
- instance = new ODataPrimitiveValueImpl();
- }
-
- @Override
- public BuilderImpl setType(final EdmType type) {
- EdmPrimitiveTypeKind primitiveTypeKind = null;
- if (type != null) {
- if (type.getKind() != EdmTypeKind.PRIMITIVE) {
- throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type));
- }
- primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName());
- }
- return setType(primitiveTypeKind);
- }
-
- @Override
- public BuilderImpl setType(final EdmPrimitiveTypeKind type) {
- if (type == EdmPrimitiveTypeKind.Stream) {
- throw new IllegalArgumentException(String.format(
- "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
- }
- if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
- throw new IllegalArgumentException(
- type + "is not an instantiable type. "
- + "An entity can declare a property to be of type Geometry. "
- + "An instance of an entity MUST NOT have a value of type Geometry. "
- + "Each value MUST be of some subtype.");
- }
-
- instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type;
- instance.type = EdmPrimitiveTypeFactory.getInstance(instance.typeKind);
-
- return this;
- }
-
- @Override
- public BuilderImpl setValue(final Object value) {
- instance.value = value;
- return this;
- }
-
- @Override
- public ODataPrimitiveValue build() {
- if (instance.type == null) {
- setType(EdmPrimitiveTypeKind.String);
- }
- return instance;
- }
-
- @Override
- public ODataPrimitiveValue buildBoolean(final Boolean value) {
- return setType(EdmPrimitiveTypeKind.Boolean).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildInt16(final Short value) {
- return setType(EdmPrimitiveTypeKind.Int16).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildInt32(final Integer value) {
- return setType(EdmPrimitiveTypeKind.Int32).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildInt64(final Long value) {
- return setType(EdmPrimitiveTypeKind.Int64).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildSingle(final Float value) {
- return setType(EdmPrimitiveTypeKind.Single).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildDouble(final Double value) {
- return setType(EdmPrimitiveTypeKind.Double).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildString(final String value) {
- return setType(EdmPrimitiveTypeKind.String).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildGuid(final UUID value) {
- return setType(EdmPrimitiveTypeKind.Guid).setValue(value).build();
- }
-
- @Override
- public ODataPrimitiveValue buildBinary(final byte[] value) {
- return setType(EdmPrimitiveTypeKind.Binary).setValue(value).build();
- }
-
- }
-
- /**
- * Type kind.
- */
- private EdmPrimitiveTypeKind typeKind;
-
- /**
- * Type.
- */
- private EdmPrimitiveType type;
-
- /**
- * Actual value.
- */
- private Object value;
-
- protected ODataPrimitiveValueImpl() {
- super(null);
- }
-
- @Override
- public String getTypeName() {
- return typeKind.getFullQualifiedName().toString();
- }
-
- @Override
- public EdmPrimitiveTypeKind getTypeKind() {
- return typeKind;
- }
-
- @Override
- public EdmPrimitiveType getType() {
- return type;
- }
-
- @Override
- public Object toValue() {
- return value;
- }
-
- @Override
- public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
- if (value == null) {
- return null;
- } else if (typeKind.isGeospatial()) {
- return reference.cast(value);
- } else {
- // TODO: set facets
- return type.valueOfString(type.valueToString(value,
- null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null),
- null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
- }
- }
-
- @Override
- public String toString() {
- if (value == null) {
- return "";
- } else if (typeKind.isGeospatial()) {
- return value.toString();
- } else {
- try {
- // TODO: set facets
- return type.valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
- } catch (EdmPrimitiveTypeException e) {
- throw new IllegalArgumentException(e);
- }
- }
- }
-
- @Override
- public boolean isEnum() {
- return false;
- }
-
- @Override
- public ODataEnumValue asEnum() {
- return null;
- }
-
- @Override
- public boolean isComplex() {
- return false;
- }
-
-}