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 2014/06/30 09:31:41 UTC
git commit: [OLINGO-317] Code clean up
Repository: olingo-odata4
Updated Branches:
refs/heads/master adcf933d5 -> 4c4f82ee5
[OLINGO-317] Code clean up
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/4c4f82ee
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/4c4f82ee
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/4c4f82ee
Branch: refs/heads/master
Commit: 4c4f82ee5f0c7e2f063bb992333699b682c6395f
Parents: adcf933
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jun 30 09:18:51 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jun 30 09:26:36 2014 +0200
----------------------------------------------------------------------
.../proxy/commons/ComplexInvocationHandler.java | 11 ++--------
.../core/serialization/v4/ODataBinderImpl.java | 1 +
.../core/serialization/AtomDeserializer.java | 1 +
.../core/serialization/JsonDeserializer.java | 21 ++++++++++----------
4 files changed, 14 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4c4f82ee/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
index 658bf65..2a71f2e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -44,8 +43,6 @@ import org.apache.olingo.ext.proxy.utils.CoreUtils;
public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
- private static final long serialVersionUID = 2629912294765040037L;
-
private static Pair<ODataComplexValue<? extends CommonODataProperty>, Class<?>> init(
final CommonEdmEnabledODataClient<?> client,
final Class<?> reference) {
@@ -151,8 +148,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
}
- for (final Iterator<? extends CommonODataProperty> itor = getComplex().iterator(); itor.hasNext();) {
- final CommonODataProperty property = itor.next();
+ for (final CommonODataProperty property : getComplex()) {
if (!propertyNames.contains(property.getName())) {
res.add(property.getName());
}
@@ -180,10 +176,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
if (value == null) {
toBeAdded = null;
} else if (Collection.class.isAssignableFrom(value.getClass())) {
- toBeAdded = new ArrayList<Object>();
- for (Object obj : (Collection) value) {
- Collection.class.cast(toBeAdded).add(obj);
- }
+ toBeAdded = new ArrayList<Object>((Collection<? extends Object>) value);
} else {
toBeAdded = value;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4c4f82ee/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
index 231e4fb..4f8fb01 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
@@ -216,6 +216,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
+ @SuppressWarnings("unchecked")
protected Object getValue(final ODataValue value) {
Object valueResource;
if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4c4f82ee/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index 11aaa35..47a373f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -122,6 +122,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
return value;
}
+ @SuppressWarnings("unchecked")
private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
throws XMLStreamException, EdmPrimitiveTypeException {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4c4f82ee/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
index d52a87c..1d830d6 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -145,7 +145,7 @@ public class JsonDeserializer implements ODataDeserializer {
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
EntitySet entitySet = new EntitySetImpl();
- Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
+ Iterator<JsonNode> entries = inline.elements();
while (entries.hasNext()) {
entitySet.getEntities().add(
entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
@@ -326,25 +326,24 @@ public class JsonDeserializer implements ODataDeserializer {
private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
throws IOException, EdmPrimitiveTypeException {
- final Object value = version.compareTo(ODataServiceVersion.V40) < 0 ?
- new ArrayList<Property>() :
- new LinkedComplexValueImpl();
- if (value instanceof LinkedComplexValue) {
+ if (version.compareTo(ODataServiceVersion.V40) < 0) {
+ List<Property> properties = new ArrayList<Property>();
+ populate(null, properties, node, codec);
+ return properties;
+ } else {
+ LinkedComplexValue linkComplexValue = new LinkedComplexValueImpl();
final Set<String> toRemove = new HashSet<String>();
for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
final Map.Entry<String, JsonNode> field = itor.next();
- links(field, (LinkedComplexValue) value, toRemove, node, codec);
+ links(field, linkComplexValue, toRemove, node, codec);
}
node.remove(toRemove);
- populate((LinkedComplexValue) value, ((LinkedComplexValue) value).getValue(), node, codec);
- } else {
- populate(null, (List<Property>) value, node, codec);
+ populate(linkComplexValue, linkComplexValue.getValue(), node, codec);
+ return linkComplexValue;
}
-
- return value;
}
private void fromCollection(Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,