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/03/22 21:12:55 UTC
olingo-odata4 git commit: [OLINGO-575] Refactore JSON deserializer
Repository: olingo-odata4
Updated Branches:
refs/heads/master eb8836e9a -> 2fa997a8f
[OLINGO-575] Refactore JSON deserializer
Conflicts:
lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java
lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyDeserializer.java
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/2fa997a8
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/2fa997a8
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/2fa997a8
Branch: refs/heads/master
Commit: 2fa997a8f15c5a37e042807727e89b8dd2a5e691
Parents: eb8836e
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Mar 18 22:57:19 2015 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Sun Mar 22 21:12:25 2015 +0100
----------------------------------------------------------------------
.../client/core/edm/xml/ActionDeserializer.java | 61 ----------------
.../olingo/client/core/edm/xml/ActionImpl.java | 43 ++++++++++-
.../client/core/edm/xml/ActionImportImpl.java | 49 +++++++------
.../core/edm/xml/AnnotationDeserializer.java | 61 ----------------
.../client/core/edm/xml/AnnotationImpl.java | 39 +++++++++-
.../core/edm/xml/AnnotationsDeserializer.java | 53 --------------
.../client/core/edm/xml/AnnotationsImpl.java | 34 ++++++++-
.../core/edm/xml/ComplexTypeDeserializer.java | 64 -----------------
.../client/core/edm/xml/ComplexTypeImpl.java | 44 +++++++++++-
.../core/edm/xml/DataServicesDeserializer.java | 52 --------------
.../client/core/edm/xml/DataServicesImpl.java | 31 +++++++-
.../client/core/edm/xml/EdmxDeserializer.java | 53 --------------
.../olingo/client/core/edm/xml/EdmxImpl.java | 32 ++++++++-
.../client/core/edm/xml/EnumMemberImpl.java | 40 +++++++----
.../core/edm/xml/IncludeAnnotationsImpl.java | 38 +++++++---
.../olingo/client/core/edm/xml/IncludeImpl.java | 30 ++++++--
.../edm/xml/NavigationPropertyBindingImpl.java | 30 +++++++-
.../edm/xml/NavigationPropertyDeserializer.java | 75 --------------------
.../core/edm/xml/NavigationPropertyImpl.java | 64 +++++++++++++----
.../client/core/edm/xml/OnDeleteImpl.java | 30 ++++++--
.../client/core/edm/xml/PropertyRefImpl.java | 36 ++++++----
.../core/edm/xml/ReferentialConstraintImpl.java | 37 ++++++----
.../olingo/client/core/edm/xml/TermImpl.java | 2 +-
.../commons/api/edm/provider/Annotation.java | 2 +-
24 files changed, 478 insertions(+), 522 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionDeserializer.java
deleted file mode 100644
index 562c8e9..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionDeserializer.java
+++ /dev/null
@@ -1,61 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.BooleanUtils;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class ActionDeserializer extends AbstractEdmDeserializer<ActionImpl> {
-
- @Override
- protected ActionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final ActionImpl action = new ActionImpl();
-
- for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Name".equals(jp.getCurrentName())) {
- action.setName(jp.nextTextValue());
- } else if ("IsBound".equals(jp.getCurrentName())) {
- action.setBound(BooleanUtils.toBoolean(jp.nextTextValue()));
- } else if ("EntitySetPath".equals(jp.getCurrentName())) {
- action.setEntitySetPath(jp.nextTextValue());
- } else if ("Parameter".equals(jp.getCurrentName())) {
- jp.nextToken();
- action.getParameters().add(jp.readValueAs(ParameterImpl.class));
- } else if ("ReturnType".equals(jp.getCurrentName())) {
- action.setReturnType(parseReturnType(jp, "Action"));
- } else if ("Annotation".equals(jp.getCurrentName())) {
- jp.nextToken();
- action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
- }
- }
- }
-
- return action;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java
index 4496daa..3aaedba 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImpl.java
@@ -18,12 +18,51 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import org.apache.commons.lang3.BooleanUtils;
import org.apache.olingo.commons.api.edm.provider.Action;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = ActionDeserializer.class)
+import java.io.IOException;
+
+@JsonDeserialize(using = ActionImpl.ActionDeserializer.class)
public class ActionImpl extends Action {
private static final long serialVersionUID = 5321541275349234088L;
-}
+
+ static class ActionDeserializer extends AbstractEdmDeserializer<ActionImpl> {
+
+ @Override
+ protected ActionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final ActionImpl action = new ActionImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ action.setName(jp.nextTextValue());
+ } else if ("IsBound".equals(jp.getCurrentName())) {
+ action.setBound(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("EntitySetPath".equals(jp.getCurrentName())) {
+ action.setEntitySetPath(jp.nextTextValue());
+ } else if ("Parameter".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ action.getParameters().add(jp.readValueAs(ParameterImpl.class));
+ } else if ("ReturnType".equals(jp.getCurrentName())) {
+ action.setReturnType(parseReturnType(jp, "Action"));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+
+ return action;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java
index 3187868..7b834a0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ActionImportImpl.java
@@ -18,34 +18,41 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.ActionImport;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = ActionImportImpl.ActionImportDeserializer.class)
public class ActionImportImpl extends ActionImport {
private static final long serialVersionUID = 2971468441177647068L;
- @Override
- @JsonProperty(value = "Action", required = true)
- public ActionImport setAction(final String action) {
- super.setAction(action);
- return this;
- }
-
- @Override
- @JsonProperty(value = "Name", required = true)
- public ActionImport setName(final String name) {
- super.setName(name);
- return this;
- }
+ static class ActionImportDeserializer extends AbstractEdmDeserializer<ActionImportImpl> {
- @Override
- @JsonProperty(value = "EntitySet")
- public ActionImport setEntitySet(final String entitySet) {
- super.setEntitySet(entitySet);
- return this;
- }
-
+ @Override
+ protected ActionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+ final ActionImportImpl action = new ActionImportImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Action".equals(jp.getCurrentName())) {
+ action.setAction(jp.nextTextValue());
+ } else if ("Name".equals(jp.getCurrentName())) {
+ action.setName(jp.nextTextValue());
+ } else if ("EntitySet".equals(jp.getCurrentName())) {
+ action.setEntitySet(jp.nextTextValue());
+ }
+ }
+ }
+
+ return action;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationDeserializer.java
deleted file mode 100644
index a81180a..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationDeserializer.java
+++ /dev/null
@@ -1,61 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import org.apache.olingo.client.core.edm.xml.annotation.AbstractDynamicAnnotationExpression;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class AnnotationDeserializer extends AbstractEdmDeserializer<AnnotationImpl> {
-
- @Override
- protected AnnotationImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final AnnotationImpl annotation = new AnnotationImpl();
-
- for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Term".equals(jp.getCurrentName())) {
- annotation.setTerm(jp.nextTextValue());
- } else if ("Qualifier".equals(jp.getCurrentName())) {
- annotation.setQualifier(jp.nextTextValue());
- } else if ("Annotation".equals(jp.getCurrentName())) {
- jp.nextToken();
- annotation.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
- } else if (isAnnotationConstExprConstruct(jp)) {
- // Constant Expressions
- annotation.setAnnotationExpression(parseAnnotationConstExprConstruct(jp));
- } else {
- // Dynamic Expressions
- annotation.setAnnotationExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
- }
- }
- }
-
- return annotation;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java
index 156cc82..95939ec 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationImpl.java
@@ -18,13 +18,50 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import org.apache.olingo.client.core.edm.xml.annotation.AbstractDynamicAnnotationExpression;
import org.apache.olingo.commons.api.edm.provider.Annotation;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = AnnotationDeserializer.class)
+@JsonDeserialize(using = AnnotationImpl.AnnotationDeserializer.class)
public class AnnotationImpl extends Annotation {
private static final long serialVersionUID = 5464714417411058033L;
+ static class AnnotationDeserializer extends AbstractEdmDeserializer<Annotation> {
+
+ @Override
+ protected Annotation doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final AnnotationImpl annotation = new AnnotationImpl();
+
+ for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Term".equals(jp.getCurrentName())) {
+ annotation.setTerm(jp.nextTextValue());
+ } else if ("Qualifier".equals(jp.getCurrentName())) {
+ annotation.setQualifier(jp.nextTextValue());
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ annotation.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ } else if (isAnnotationConstExprConstruct(jp)) {
+ // Constant Expressions
+ annotation.setExpression(parseAnnotationConstExprConstruct(jp));
+ } else {
+ // Dynamic Expressions
+ annotation.setExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
+ }
+ }
+ }
+
+ return annotation;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsDeserializer.java
deleted file mode 100644
index 14d84ca..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsDeserializer.java
+++ /dev/null
@@ -1,53 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class AnnotationsDeserializer extends AbstractEdmDeserializer<AnnotationsImpl> {
-
- @Override
- protected AnnotationsImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final AnnotationsImpl annotations = new AnnotationsImpl();
-
- for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Target".equals(jp.getCurrentName())) {
- annotations.setTarget(jp.nextTextValue());
- } else if ("Qualifier".equals(jp.getCurrentName())) {
- annotations.setQualifier(jp.nextTextValue());
- } else if ("Annotation".equals(jp.getCurrentName())) {
- jp.nextToken();
- annotations.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
- }
- }
- }
-
- return annotations;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java
index 053fdf2..21aff68 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AnnotationsImpl.java
@@ -18,13 +18,45 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
import org.apache.olingo.commons.api.edm.provider.Annotations;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = AnnotationsDeserializer.class)
+import java.io.IOException;
+
+@JsonDeserialize(using = AnnotationsImpl.AnnotationsDeserializer.class)
public class AnnotationsImpl extends Annotations {
private static final long serialVersionUID = -5961207981571644200L;
+ static class AnnotationsDeserializer extends AbstractEdmDeserializer<AnnotationsImpl> {
+
+ @Override
+ protected AnnotationsImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final AnnotationsImpl annotations = new AnnotationsImpl();
+
+ for (; jp.getCurrentToken() != null && jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Target".equals(jp.getCurrentName())) {
+ annotations.setTarget(jp.nextTextValue());
+ } else if ("Qualifier".equals(jp.getCurrentName())) {
+ annotations.setQualifier(jp.nextTextValue());
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ annotations.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+
+ return annotations;
+ }
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java
deleted file mode 100644
index 65077dc..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java
+++ /dev/null
@@ -1,64 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.BooleanUtils;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class ComplexTypeDeserializer extends AbstractEdmDeserializer<ComplexTypeImpl> {
-
- @Override
- protected ComplexTypeImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final ComplexTypeImpl complexType = new ComplexTypeImpl();
-
- for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Name".equals(jp.getCurrentName())) {
- complexType.setName(jp.nextTextValue());
- } else if ("Abstract".equals(jp.getCurrentName())) {
- complexType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue()));
- } else if ("BaseType".equals(jp.getCurrentName())) {
- complexType.setBaseType(jp.nextTextValue());
- } else if ("OpenType".equals(jp.getCurrentName())) {
- complexType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
- } else if ("Property".equals(jp.getCurrentName())) {
- jp.nextToken();
- complexType.getProperties().add(jp.readValueAs(PropertyImpl.class));
- } else if ("NavigationProperty".equals(jp.getCurrentName())) {
- jp.nextToken();
- complexType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class));
- } else if ("Annotation".equals(jp.getCurrentName())) {
- jp.nextToken();
- complexType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
- }
- }
- }
-
- return complexType;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java
index dd89b02..af0b1d6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeImpl.java
@@ -18,13 +18,55 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import org.apache.commons.lang3.BooleanUtils;
import org.apache.olingo.commons.api.edm.provider.ComplexType;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = ComplexTypeDeserializer.class)
+import java.io.IOException;
+
+@JsonDeserialize(using = ComplexTypeImpl.ComplexTypeDeserializer.class)
public class ComplexTypeImpl extends ComplexType {
private static final long serialVersionUID = 4076944306925840115L;
+ static class ComplexTypeDeserializer extends AbstractEdmDeserializer<ComplexType> {
+
+ @Override
+ protected ComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final ComplexTypeImpl complexType = new ComplexTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ complexType.setName(jp.nextTextValue());
+ } else if ("Abstract".equals(jp.getCurrentName())) {
+ complexType.setAbstract(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("BaseType".equals(jp.getCurrentName())) {
+ complexType.setBaseType(jp.nextTextValue());
+ } else if ("OpenType".equals(jp.getCurrentName())) {
+ complexType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Property".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ complexType.getProperties().add(jp.readValueAs(PropertyImpl.class));
+ } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ complexType.getNavigationProperties().add(jp.readValueAs(NavigationPropertyImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ complexType.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+
+ return complexType;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesDeserializer.java
deleted file mode 100644
index efbea76..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesDeserializer.java
+++ /dev/null
@@ -1,52 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class DataServicesDeserializer extends AbstractEdmDeserializer<DataServicesImpl> {
-
- @Override
- protected DataServicesImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final DataServicesImpl dataServices = new DataServicesImpl();
-
- for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("DataServiceVersion".equals(jp.getCurrentName())) {
- dataServices.setDataServiceVersion(jp.nextTextValue());
- } else if ("MaxDataServiceVersion".equals(jp.getCurrentName())) {
- dataServices.setMaxDataServiceVersion(jp.nextTextValue());
- } else if ("Schema".equals(jp.getCurrentName())) {
- jp.nextToken();
- dataServices.getSchemas().add(jp.readValueAs(SchemaImpl.class));
- }
- }
- }
-
- return dataServices;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java
index 208f77b..e446e29 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/DataServicesImpl.java
@@ -18,16 +18,20 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
import org.apache.olingo.client.api.edm.xml.DataServices;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem;
import org.apache.olingo.commons.api.edm.provider.Schema;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = DataServicesDeserializer.class)
+@JsonDeserialize(using = DataServicesImpl.DataServicesDeserializer.class)
public class DataServicesImpl extends AbstractEdmItem implements DataServices {
private static final long serialVersionUID = 4200317286476885204L;
@@ -61,4 +65,29 @@ public class DataServicesImpl extends AbstractEdmItem implements DataServices {
return schemas;
}
+ static class DataServicesDeserializer extends AbstractEdmDeserializer<DataServicesImpl> {
+
+ @Override
+ protected DataServicesImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final DataServicesImpl dataServices = new DataServicesImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("DataServiceVersion".equals(jp.getCurrentName())) {
+ dataServices.setDataServiceVersion(jp.nextTextValue());
+ } else if ("MaxDataServiceVersion".equals(jp.getCurrentName())) {
+ dataServices.setMaxDataServiceVersion(jp.nextTextValue());
+ } else if ("Schema".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ dataServices.getSchemas().add(jp.readValueAs(SchemaImpl.class));
+ }
+ }
+ }
+
+ return dataServices;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxDeserializer.java
deleted file mode 100644
index 854077f..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxDeserializer.java
+++ /dev/null
@@ -1,53 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class EdmxDeserializer extends AbstractEdmDeserializer<EdmxImpl> {
-
- @Override
- protected EdmxImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final EdmxImpl edmx = new EdmxImpl();
-
- for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Version".equals(jp.getCurrentName())) {
- edmx.setVersion(jp.nextTextValue());
- } else if ("DataServices".equals(jp.getCurrentName())) {
- jp.nextToken();
- edmx.setDataServices(jp.readValueAs(DataServicesImpl.class));
- } else if ("Reference".equals(jp.getCurrentName())) {
- jp.nextToken();
- edmx.getReferences().add(jp.readValueAs(ReferenceImpl.class));
- }
- }
- }
-
- return edmx;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java
index 5836704..6eb7365 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EdmxImpl.java
@@ -18,9 +18,13 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
import org.apache.olingo.client.api.edm.xml.DataServices;
import org.apache.olingo.client.api.edm.xml.Edmx;
import org.apache.olingo.client.api.edm.xml.Reference;
@@ -28,7 +32,7 @@ import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = EdmxDeserializer.class)
+@JsonDeserialize(using = EdmxImpl.EdmxDeserializer.class)
public class EdmxImpl extends AbstractEdmItem implements Edmx {
private static final long serialVersionUID = -6293476719276092572L;
@@ -62,4 +66,30 @@ public class EdmxImpl extends AbstractEdmItem implements Edmx {
return references;
}
+ static class EdmxDeserializer extends AbstractEdmDeserializer<EdmxImpl> {
+
+ @Override
+ protected EdmxImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final EdmxImpl edmx = new EdmxImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Version".equals(jp.getCurrentName())) {
+ edmx.setVersion(jp.nextTextValue());
+ } else if ("DataServices".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ edmx.setDataServices(jp.readValueAs(DataServicesImpl.class));
+ } else if ("Reference".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ edmx.getReferences().add(jp.readValueAs(ReferenceImpl.class));
+ }
+ }
+ }
+
+ return edmx;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java
index 7af8171..74588a1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EnumMemberImpl.java
@@ -18,26 +18,40 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.EnumMember;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = EnumMemberImpl.EnumMemberDeserializer.class)
public class EnumMemberImpl extends EnumMember {
private static final long serialVersionUID = -6138606817225829791L;
- @Override
- @JsonProperty(value = "Name", required = true)
- public EnumMember setName(final String name) {
- super.setName(name);
- return this;
- }
+ static class EnumMemberDeserializer extends AbstractEdmDeserializer<EnumMember> {
+ @Override
+ protected EnumMember doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
- @Override
- @JsonProperty("Value")
- public EnumMember setValue(final String value) {
- super.setValue(value);
- return this;
- }
+ final EnumMember member = new EnumMember();
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ member.setName(jp.nextTextValue());
+ } else if ("Value".equals(jp.getCurrentName())) {
+ member.setValue(jp.nextTextValue());
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ member.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+ return member;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeAnnotationsImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeAnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeAnnotationsImpl.java
index f5d7ed7..ccea81b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeAnnotationsImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeAnnotationsImpl.java
@@ -18,22 +18,22 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.client.api.edm.xml.IncludeAnnotations;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = IncludeAnnotationsImpl.IncludeAnnotationsDeserializer.class)
public class IncludeAnnotationsImpl extends AbstractEdmItem implements IncludeAnnotations {
private static final long serialVersionUID = -8157841387011422396L;
- @JsonProperty(value = "TermNamespace", required = true)
private String termNamespace;
-
- @JsonProperty(value = "Qualifier")
private String qualifier;
-
- @JsonProperty(value = "TargetNamespace")
private String targetNamespace;
@Override
@@ -59,8 +59,30 @@ public class IncludeAnnotationsImpl extends AbstractEdmItem implements IncludeAn
return targetNamespace;
}
- public void setTargeyNamespace(final String targeyNamespace) {
- this.targetNamespace = targeyNamespace;
+ public void setTargetNamespace(final String targetNamespace) {
+ this.targetNamespace = targetNamespace;
}
+ static class IncludeAnnotationsDeserializer extends AbstractEdmDeserializer<IncludeAnnotations> {
+ @Override
+ protected IncludeAnnotations doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final IncludeAnnotationsImpl member = new IncludeAnnotationsImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("TermNamespace".equals(jp.getCurrentName())) {
+ member.setTermNamespace(jp.nextTextValue());
+ } else if ("Qualifier".equals(jp.getCurrentName())) {
+ member.setQualifier(jp.nextTextValue());
+ } else if ("TargetNamespace".equals(jp.getCurrentName())) {
+ member.setTargetNamespace(jp.nextTextValue());
+ }
+ }
+ }
+ return member;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeImpl.java
index 973e27f..55ac505 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/IncludeImpl.java
@@ -18,19 +18,21 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.client.api.edm.xml.Include;
import org.apache.olingo.commons.api.edm.provider.AbstractEdmItem;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = IncludeImpl.IncludeDeserializer.class)
public class IncludeImpl extends AbstractEdmItem implements Include {
private static final long serialVersionUID = -5450008299655584221L;
- @JsonProperty(value = "Namespace", required = true)
private String namespace;
-
- @JsonProperty(value = "Alias")
private String alias;
@Override
@@ -51,4 +53,24 @@ public class IncludeImpl extends AbstractEdmItem implements Include {
this.alias = alias;
}
+ static class IncludeDeserializer extends AbstractEdmDeserializer<Include> {
+ @Override
+ protected Include doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final IncludeImpl include = new IncludeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Namespace".equals(jp.getCurrentName())) {
+ include.setNamespace(jp.nextTextValue());
+ } else if ("Alias".equals(jp.getCurrentName())) {
+ include.setAlias(jp.nextTextValue());
+ }
+ }
+ }
+ return include;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyBindingImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyBindingImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyBindingImpl.java
index cded45d..c01707f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyBindingImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyBindingImpl.java
@@ -18,25 +18,49 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = NavigationPropertyBindingImpl.NavigationPropertyBindingDeserializer.class)
public class NavigationPropertyBindingImpl extends NavigationPropertyBinding {
private static final long serialVersionUID = -7056978592235483660L;
@Override
- @JsonProperty(value = "Path", required = true)
public NavigationPropertyBinding setPath(final String path) {
super.setPath(path);
return this;
}
@Override
- @JsonProperty(value = "Target", required = true)
public NavigationPropertyBinding setTarget(final String target) {
super.setTarget(target);
return this;
}
+
+ static class NavigationPropertyBindingDeserializer extends AbstractEdmDeserializer<NavigationPropertyBinding> {
+ @Override
+ protected NavigationPropertyBinding doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final NavigationPropertyBindingImpl member = new NavigationPropertyBindingImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Path".equals(jp.getCurrentName())) {
+ member.setPath(jp.nextTextValue());
+ } else if ("Target".equals(jp.getCurrentName())) {
+ member.setTarget(jp.nextTextValue());
+ }
+ }
+ }
+ return member;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyDeserializer.java
deleted file mode 100644
index 40a5ffb..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyDeserializer.java
+++ /dev/null
@@ -1,75 +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.client.core.edm.xml;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.BooleanUtils;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class NavigationPropertyDeserializer extends AbstractEdmDeserializer<NavigationPropertyImpl> {
-
- @Override
- protected NavigationPropertyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
-
- final NavigationPropertyImpl property = new NavigationPropertyImpl();
-
- for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
- final JsonToken token = jp.getCurrentToken();
- if (token == JsonToken.FIELD_NAME) {
- if ("Name".equals(jp.getCurrentName())) {
- property.setName(jp.nextTextValue());
- } else if ("Type".equals(jp.getCurrentName())) {
- String metadataTypeName = jp.nextTextValue();
- if (metadataTypeName.startsWith("Collection(")) {
- property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
- metadataTypeName.length() - 1));
- property.setCollection(true);
- } else {
- property.setType(metadataTypeName);
- property.setCollection(false);
- }
- } else if ("Nullable".equals(jp.getCurrentName())) {
- property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
- } else if ("Partner".equals(jp.getCurrentName())) {
- property.setPartner(jp.nextTextValue());
- } else if ("ContainsTarget".equals(jp.getCurrentName())) {
- property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue()));
- } else if ("ReferentialConstraint".equals(jp.getCurrentName())) {
- jp.nextToken();
- property.getReferentialConstraints().add(jp.readValueAs(ReferentialConstraintImpl.class));
- } else if ("OnDelete".equals(jp.getCurrentName())) {
- jp.nextToken();
- property.setOnDelete(jp.readValueAs(OnDeleteImpl.class));
- } else if ("Annotation".equals(jp.getCurrentName())) {
- jp.nextToken();
- property.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
- }
- }
- }
-
- return property;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyImpl.java
index 072f3e9..904a57d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/NavigationPropertyImpl.java
@@ -18,27 +18,63 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import org.apache.commons.lang3.BooleanUtils;
import org.apache.olingo.commons.api.edm.provider.NavigationProperty;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-@JsonDeserialize(using = NavigationPropertyDeserializer.class)
+import java.io.IOException;
+
+@JsonDeserialize(using = NavigationPropertyImpl.NavigationPropertyDeserializer.class)
public class NavigationPropertyImpl extends NavigationProperty {
private static final long serialVersionUID = 6240231735592427582L;
- @Override
- @JsonProperty(value = "Name", required = true)
- public NavigationProperty setName(final String name) {
- super.setName(name);
- return this;
- }
+ static class NavigationPropertyDeserializer extends AbstractEdmDeserializer<NavigationProperty> {
+
+ @Override
+ protected NavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final NavigationProperty property = new NavigationPropertyImpl();
- @Override
- @JsonProperty(value = "ContainsTarget")
- public NavigationProperty setContainsTarget(final boolean containsTarget) {
- super.setContainsTarget(containsTarget);
- return this;
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ property.setName(jp.nextTextValue());
+ } else if ("Type".equals(jp.getCurrentName())) {
+ String metadataTypeName = jp.nextTextValue();
+ if (metadataTypeName.startsWith("Collection(")) {
+ property.setType(metadataTypeName.substring(metadataTypeName.indexOf("(") + 1,
+ metadataTypeName.length() - 1));
+ property.setCollection(true);
+ } else {
+ property.setType(metadataTypeName);
+ property.setCollection(false);
+ }
+ } else if ("Nullable".equals(jp.getCurrentName())) {
+ property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Partner".equals(jp.getCurrentName())) {
+ property.setPartner(jp.nextTextValue());
+ } else if ("ContainsTarget".equals(jp.getCurrentName())) {
+ property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("ReferentialConstraint".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ property.getReferentialConstraints().add(jp.readValueAs(ReferentialConstraintImpl.class));
+ } else if ("OnDelete".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ property.setOnDelete(jp.readValueAs(OnDeleteImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ property.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+ return property;
+ }
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/OnDeleteImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/OnDeleteImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/OnDeleteImpl.java
index 9062e01..9228c4c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/OnDeleteImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/OnDeleteImpl.java
@@ -18,19 +18,37 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.OnDelete;
import org.apache.olingo.commons.api.edm.provider.OnDeleteAction;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = OnDeleteImpl.OnDeleteDeserializer.class)
public class OnDeleteImpl extends OnDelete {
private static final long serialVersionUID = -7130889202653716784L;
- @Override
- @JsonProperty(value = "Action", required = true)
- public OnDelete setAction(final OnDeleteAction action) {
- super.setAction(action);
- return this;
+ static class OnDeleteDeserializer extends AbstractEdmDeserializer<OnDelete> {
+ @Override
+ protected OnDelete doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final OnDelete ondelete = new OnDeleteImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Action".equals(jp.getCurrentName())) {
+ OnDeleteAction action = OnDeleteAction.valueOf(jp.nextTextValue());
+ ondelete.setAction(action);
+ }
+ }
+ }
+ return ondelete;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyRefImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyRefImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyRefImpl.java
index 5b3a41c..6fc5434 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyRefImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/PropertyRefImpl.java
@@ -18,25 +18,37 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = PropertyRefImpl.PropertyRefDeserializer.class)
public class PropertyRefImpl extends PropertyRef {
private static final long serialVersionUID = 1504095609268590326L;
- @Override
- @JsonProperty(value = "Name", required = true)
- public PropertyRef setName(final String name) {
- super.setName(name);
- return this;
- }
+ static class PropertyRefDeserializer extends AbstractEdmDeserializer<PropertyRef> {
+ @Override
+ protected PropertyRef doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
+
+ final PropertyRef propertyRef = new PropertyRefImpl();
- @Override
- @JsonProperty(value = "Alias")
- public PropertyRef setAlias(final String alias) {
- super.setAlias(alias);
- return this;
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ propertyRef.setName(jp.nextTextValue());
+ } else if ("Alias".equals(jp.getCurrentName())) {
+ propertyRef.setAlias(jp.nextTextValue());
+ }
+ }
+ }
+ return propertyRef;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferentialConstraintImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferentialConstraintImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferentialConstraintImpl.java
index 8e7dfbb..a09fc11 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferentialConstraintImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ReferentialConstraintImpl.java
@@ -18,26 +18,37 @@
*/
package org.apache.olingo.client.core.edm.xml;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.IOException;
+@JsonDeserialize(using = ReferentialConstraintImpl.ReferentialConstraintDeserializer.class)
public class ReferentialConstraintImpl extends ReferentialConstraint {
private static final long serialVersionUID = -5822115908069878139L;
- @Override
- @JsonProperty(value = "Property", required = true)
- public ReferentialConstraint setProperty(final String property) {
- super.setProperty(property);
- return this;
- }
+ static class ReferentialConstraintDeserializer extends AbstractEdmDeserializer<ReferentialConstraint> {
+ @Override
+ protected ReferentialConstraint doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException {
- @Override
- @JsonProperty(value = "ReferencedProperty", required = true)
- public ReferentialConstraint setReferencedProperty(final String referencedProperty) {
- super.setReferencedProperty(referencedProperty);
- return this;
- }
+ final ReferentialConstraint refConst = new ReferentialConstraintImpl();
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Property".equals(jp.getCurrentName())) {
+ refConst.setProperty(jp.nextTextValue());
+ } else if ("ReferencedProperty".equals(jp.getCurrentName())) {
+ refConst.setReferencedProperty(jp.nextTextValue());
+ }
+ }
+ }
+ return refConst;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java
index e039dab..fe1839e 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/TermImpl.java
@@ -23,7 +23,7 @@ import org.apache.olingo.commons.api.edm.provider.Term;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize(using = TermDeserializer.class)
-public class TermImpl extends Term {
+public class TermImpl extends Term {
private static final long serialVersionUID = -8350072064720586186L;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2fa997a8/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java
index 173cf3e..67791c9 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Annotation.java
@@ -39,7 +39,7 @@ public class Annotation extends AbstractEdmItem implements Annotatable {
return annotationExpression;
}
- public void setAnnotationExpression(final AnnotationExpression annotationExpression) {
+ public void setExpression(final AnnotationExpression annotationExpression) {
this.annotationExpression = annotationExpression;
}