You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/03/06 18:21:36 UTC

[1/2] olingo-odata4 git commit: [OLINGO-575] Delete unnecessary casts

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 9a666bd95 -> f46364072


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
index 0cc1ca6..30ca77a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java
@@ -50,10 +50,8 @@ import org.apache.olingo.commons.core.edm.AbstractEdmSchema;
 
 public class EdmSchemaImpl extends AbstractEdmSchema {
 
-
   private final Edm edm;
 
-  private final List<Schema> xmlSchemas;
 
   private final Schema schema;
 
@@ -61,12 +59,11 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
 
   private List<EdmEntityContainer> entityContainers;
 
-  public EdmSchemaImpl(final Edm edm, final List<Schema> xmlSchemas, final Schema schema) {
+  public EdmSchemaImpl(final Edm edm, final Schema schema) {
 
     super(schema.getNamespace(), schema.getAlias());
 
     this.edm = edm;
-    this.xmlSchemas = xmlSchemas;
     this.schema = schema;
   }
 
@@ -75,20 +72,9 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
     if (entityContainers == null) {
       entityContainerByName = new HashMap<FullQualifiedName, EdmEntityContainer>();
 
-      if (schema instanceof Schema) {
-        entityContainers = super.getEntityContainers();
-        if (getEntityContainer() != null) {
-          entityContainerByName.put(getEntityContainer().getFullQualifiedName(), getEntityContainer());
-        }
-      } else {
-        entityContainers = new ArrayList<EdmEntityContainer>(schema.getEntityContainers().size());
-        for (EntityContainer entityContainer : schema.getEntityContainers()) {
-          final EdmEntityContainer edmContainer = createEntityContainer(entityContainer.getName());
-          if (edmContainer != null) {
-            entityContainers.add(edmContainer);
-            entityContainerByName.put(edmContainer.getFullQualifiedName(), edmContainer);
-          }
-        }
+      entityContainers = super.getEntityContainers();
+      if (getEntityContainer() != null) {
+        entityContainerByName.put(getEntityContainer().getFullQualifiedName(), getEntityContainer());
       }
     }
 
@@ -106,7 +92,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
     if (defaultContainer != null) {
       final FullQualifiedName entityContainerName =
           new FullQualifiedName(schema.getNamespace(), defaultContainer.getName());
-      return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer, xmlSchemas);
+      return new EdmEntityContainerImpl(edm, entityContainerName, defaultContainer);
     }
     return null;
   }
@@ -123,14 +109,12 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmTypeDefinition> createTypeDefinitions() {
     final List<EdmTypeDefinition> typeDefinitions = new ArrayList<EdmTypeDefinition>();
-    if (schema instanceof Schema) {
-      final List<TypeDefinition> providerTypeDefinitions =
-          ((Schema) schema).getTypeDefinitions();
-      if (providerTypeDefinitions != null) {
-        for (TypeDefinition def : providerTypeDefinitions) {
-          typeDefinitions.add(
-              new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace, def.getName()), def));
-        }
+    final List<TypeDefinition> providerTypeDefinitions =
+        schema.getTypeDefinitions();
+    if (providerTypeDefinitions != null) {
+      for (TypeDefinition def : providerTypeDefinitions) {
+        typeDefinitions.add(
+            new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace, def.getName()), def));
       }
     }
     return typeDefinitions;
@@ -156,7 +140,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
     if (providerEntityTypes != null) {
       for (EntityType entityType : providerEntityTypes) {
         entityTypes.add(EdmEntityTypeImpl.getInstance(edm,
-            new FullQualifiedName(namespace, entityType.getName()), xmlSchemas, entityType));
+            new FullQualifiedName(namespace, entityType.getName()), entityType));
       }
     }
     return entityTypes;
@@ -169,7 +153,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
     if (providerComplexTypes != null) {
       for (ComplexType complexType : providerComplexTypes) {
         complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()),
-            xmlSchemas, complexType));
+            complexType));
       }
     }
     return complexTypes;
@@ -178,12 +162,10 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmAction> createActions() {
     final List<EdmAction> actions = new ArrayList<EdmAction>();
-    if (schema instanceof Schema) {
-      final List<Action> providerActions = ((Schema) schema).getActions();
-      if (providerActions != null) {
-        for (Action action : providerActions) {
-          actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
-        }
+    final List<Action> providerActions = schema.getActions();
+    if (providerActions != null) {
+      for (Action action : providerActions) {
+        actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action));
       }
     }
     return actions;
@@ -192,15 +174,13 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmFunction> createFunctions() {
     final List<EdmFunction> functions = new ArrayList<EdmFunction>();
-    if (schema instanceof Schema) {
-      final List<Function> providerFunctions = ((Schema) schema).getFunctions();
-      if (providerFunctions != null) {
-        for (Function function : providerFunctions) {
-          functions.add(
-              EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
-        }
-        return functions;
+    final List<Function> providerFunctions = schema.getFunctions();
+    if (providerFunctions != null) {
+      for (Function function : providerFunctions) {
+        functions.add(
+            EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function));
       }
+      return functions;
     }
     return functions;
   }
@@ -208,12 +188,10 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmTerm> createTerms() {
     final List<EdmTerm> terms = new ArrayList<EdmTerm>();
-    if (schema instanceof Schema) {
-      final List<Term> providerTerms = ((Schema) schema).getTerms();
-      if (providerTerms != null) {
-        for (Term term : providerTerms) {
-          terms.add(new EdmTermImpl(edm, getNamespace(), term));
-        }
+    final List<Term> providerTerms = schema.getTerms();
+    if (providerTerms != null) {
+      for (Term term : providerTerms) {
+        terms.add(new EdmTermImpl(edm, getNamespace(), term));
       }
     }
     return terms;
@@ -222,13 +200,11 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmAnnotations> createAnnotationGroups() {
     final List<EdmAnnotations> annotationGroups = new ArrayList<EdmAnnotations>();
-    if (schema instanceof Schema) {
-      final List<Annotations> providerAnnotations =
-          ((Schema) schema).getAnnotationGroups();
-      if (providerAnnotations != null) {
-        for (Annotations annotationGroup : providerAnnotations) {
-          annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup));
-        }
+    final List<Annotations> providerAnnotations =
+        schema.getAnnotationGroups();
+    if (providerAnnotations != null) {
+      for (Annotations annotationGroup : providerAnnotations) {
+        annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup));
       }
     }
     return annotationGroups;
@@ -237,13 +213,11 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
   @Override
   protected List<EdmAnnotation> createAnnotations() {
     final List<EdmAnnotation> annotations = new ArrayList<EdmAnnotation>();
-    if (schema instanceof Schema) {
-      final List<Annotation> providerAnnotations =
-          ((Schema) schema).getAnnotations();
-      if (providerAnnotations != null) {
-        for (Annotation annotation : providerAnnotations) {
-          annotations.add(new EdmAnnotationImpl(edm, annotation));
-        }
+    final List<Annotation> providerAnnotations =
+        schema.getAnnotations();
+    if (providerAnnotations != null) {
+      for (Annotation annotation : providerAnnotations) {
+        annotations.add(new EdmAnnotationImpl(edm, annotation));
       }
     }
     return annotations;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
index 127dfad..ac98306 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java
@@ -19,14 +19,12 @@
 package org.apache.olingo.client.core.edm;
 
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.olingo.client.api.edm.xml.ComplexType;
 import org.apache.olingo.client.api.edm.xml.EntityType;
 import org.apache.olingo.client.api.edm.xml.NavigationProperty;
 import org.apache.olingo.client.api.edm.xml.Property;
-import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.client.api.edm.xml.StructuralType;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
@@ -47,7 +45,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
   private Map<String, EdmNavigationProperty> navigationProperties;
 
   public EdmStructuredTypeHelperImpl(final Edm edm, final FullQualifiedName structuredTypeName,
-      final List<? extends Schema> xmlSchemas, final StructuralType structuralType) {
+      final StructuralType structuralType) {
 
     this.edm = edm;
     this.structuredTypeName = structuredTypeName;
@@ -70,11 +68,8 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
     if (navigationProperties == null) {
       navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
       for (NavigationProperty navigationProperty : structuralType.getNavigationProperties()) {
-        if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.NavigationProperty) {
-          navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(
-              edm, structuredTypeName,
-              (org.apache.olingo.client.api.edm.xml.NavigationProperty) navigationProperty));
-        }
+        navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(
+            edm, structuredTypeName, navigationProperty));
       }
     }
     return navigationProperties;
@@ -83,9 +78,9 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
   @Override
   public boolean isOpenType() {
     boolean isOpen = false;
-    if(structuralType instanceof ComplexType){
+    if (structuralType instanceof ComplexType) {
       isOpen = ((ComplexType) structuralType).isOpenType();
-    }else if(structuralType instanceof EntityType){
+    } else if (structuralType instanceof EntityType) {
       isOpen = ((EntityType) structuralType).isOpenType();
     }
     return isOpen;
@@ -94,9 +89,9 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
   @Override
   public boolean isAbstract() {
     boolean isAbstract = false;
-    if(structuralType instanceof ComplexType){
+    if (structuralType instanceof ComplexType) {
       isAbstract = ((ComplexType) structuralType).isAbstractType();
-    }else if(structuralType instanceof EntityType){
+    } else if (structuralType instanceof EntityType) {
       isAbstract = ((EntityType) structuralType).isAbstractType();
     }
     return isAbstract;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/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 4fc0ce9..fdd499d 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
@@ -74,7 +74,7 @@ public class ComplexTypeImpl extends AbstractStructuralType implements ComplexTy
 
   @Override
   public Property getProperty(final String name) {
-    return (Property) super.getProperty(name);
+    return super.getProperty(name);
   }
 
   @Override
@@ -84,7 +84,7 @@ public class ComplexTypeImpl extends AbstractStructuralType implements ComplexTy
 
   @Override
   public NavigationProperty getNavigationProperty(final String name) {
-    return (NavigationProperty) super.getNavigationProperty(name);
+    return super.getNavigationProperty(name);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java
index 0567506..217747d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/EntityTypeImpl.java
@@ -97,7 +97,7 @@ public class EntityTypeImpl extends AbstractStructuralType implements EntityType
   
   @Override
   public Property getProperty(final String name) {
-    return (Property) super.getProperty(name);
+    return super.getProperty(name);
   }
 
   @Override
@@ -107,7 +107,7 @@ public class EntityTypeImpl extends AbstractStructuralType implements EntityType
 
   @Override
   public NavigationProperty getNavigationProperty(final String name) {
-    return (NavigationProperty) super.getNavigationProperty(name);
+    return super.getNavigationProperty(name);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/XMLMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/XMLMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/XMLMetadataImpl.java
index df633f5..d4709b6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/XMLMetadataImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/XMLMetadataImpl.java
@@ -69,6 +69,6 @@ public class XMLMetadataImpl extends AbstractEdmItem implements XMLMetadata {
 
   @Override
   public List<Reference> getReferences() {
-    return ((Edmx) this.edmx).getReferences();
+    return this.edmx.getReferences();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrappingHttpClientFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrappingHttpClientFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrappingHttpClientFactory.java
index 9d72512..6b8aec2 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrappingHttpClientFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/http/ProxyWrappingHttpClientFactory.java
@@ -65,6 +65,7 @@ public class ProxyWrappingHttpClientFactory implements WrappingHttpClientFactory
     this.wrapped = wrapped;
   }
 
+  @Override
   public DefaultHttpClientFactory getWrappedHttpClientFactory() {
     return this.wrapped;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index 4dd1658..cd5003d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@ -70,18 +70,22 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
     }
   }
 
+  @Override
   public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
     return deserializer.toEntitySet(input);
   }
 
+  @Override
   public ResWrap<Entity> toEntity(final InputStream input) throws ODataDeserializerException {
     return deserializer.toEntity(input);
   }
 
+  @Override
   public ResWrap<Property> toProperty(final InputStream input) throws ODataDeserializerException {
     return deserializer.toProperty(input);
   }
 
+  @Override
   public ODataError toError(final InputStream input) throws ODataDeserializerException {
     return deserializer.toError(input);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index ccf7c81..17c4403 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -118,11 +118,11 @@ public class ODataBinderImpl implements ODataBinder {
 
   @Override
   public boolean add(final ODataEntity entity, final ODataProperty property) {
-    return ((ODataEntity) entity).getProperties().add((ODataProperty) property);
+    return entity.getProperties().add(property);
   }
 
   protected boolean add(final ODataEntitySet entitySet, final ODataEntity entity) {
-    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) entity);
+    return entitySet.getEntities().add(entity);
   }
 
   @Override
@@ -212,8 +212,8 @@ public class ODataBinderImpl implements ODataBinder {
       entitySet.getEntities().add(getEntity(entity));
     }
 
-    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
-    annotations((ODataEntitySet) odataEntitySet, entitySet);
+    entitySet.setDeltaLink(odataEntitySet.getDeltaLink());
+    annotations(odataEntitySet, entitySet);
     return entitySet;
   }
 
@@ -241,7 +241,7 @@ public class ODataBinderImpl implements ODataBinder {
     for (Link link : linked.getNavigationLinks()) {
       final ODataLink odataLink = odataLinked.getNavigationLink(link.getTitle());
       if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof ODataInlineEntitySet)) {
-        annotations((ODataLink) odataLink, link);
+        annotations(odataLink, link);
       }
     }
   }
@@ -294,8 +294,8 @@ public class ODataBinderImpl implements ODataBinder {
       entity.getProperties().add(getProperty(property));
     }
 
-    entity.setId(((ODataEntity) odataEntity).getId());
-    annotations((ODataEntity) odataEntity, entity);
+    entity.setId(odataEntity.getId());
+    annotations(odataEntity, entity);
     return entity;
   }
 
@@ -327,7 +327,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   @Override
   public Property getProperty(final ODataProperty property) {
-    final ODataProperty _property = (ODataProperty) property;
+    final ODataProperty _property = property;
 
     final Property propertyResource = new PropertyImpl();
     propertyResource.setName(_property.getName());
@@ -340,8 +340,9 @@ public class ODataBinderImpl implements ODataBinder {
   protected Object getValue(final ODataValue value) {
     Object valueResource = null;
     if (value == null) {
-      valueResource = null;
-    } else if (value.isEnum()) {
+      return null;
+    }
+    if (value.isEnum()) {
       valueResource = value.asEnum().getValue();
     } else if (value.isPrimitive()) {
       valueResource = value.asPrimitive().toValue();
@@ -386,8 +387,8 @@ public class ODataBinderImpl implements ODataBinder {
         }
       }
 
-      final ODataAnnotation odataAnnotation = new ODataAnnotationImpl(annotation.getTerm(),
-          (org.apache.olingo.commons.api.domain.ODataValue) getODataValue(fqn, annotation, null, null));
+      final ODataAnnotation odataAnnotation =
+          new ODataAnnotationImpl(annotation.getTerm(), getODataValue(fqn, annotation, null, null));
       odataAnnotatable.getAnnotations().add(odataAnnotation);
     }
   }
@@ -398,7 +399,9 @@ public class ODataBinderImpl implements ODataBinder {
       final StringWriter writer = new StringWriter();
       try {
         client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
+      }
       writer.flush();
       LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
     }
@@ -465,9 +468,9 @@ public class ODataBinderImpl implements ODataBinder {
       }
     }
 
-    for (org.apache.olingo.commons.api.domain.ODataLink link : odataLinked.getNavigationLinks()) {
+    for (ODataLink link : odataLinked.getNavigationLinks()) {
       if (!(link instanceof ODataInlineEntity) && !(link instanceof ODataInlineEntitySet)) {
-        odataAnnotations(linked.getNavigationLink(link.getName()), (ODataAnnotatable) link);
+        odataAnnotations(linked.getNavigationLink(link.getName()), link);
       }
     }
   }
@@ -593,7 +596,9 @@ public class ODataBinderImpl implements ODataBinder {
       final StringWriter writer = new StringWriter();
       try {
         client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
+      }
       writer.flush();
       LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
     }
@@ -743,11 +748,11 @@ public class ODataBinderImpl implements ODataBinder {
 
     ODataValue value = null;
     if (valuable.isEnum()) {
-      value = ((ODataClient) client).getObjectFactory().newEnumValue(type == null ? null : type.toString(),
+      value = client.getObjectFactory().newEnumValue(type == null ? null : type.toString(),
           valuable.asEnum().toString());
     } else if (valuable.isComplex()) {
       final ODataComplexValue lcValue =
-          ((ODataClient) client).getObjectFactory().newComplexValue(type == null ? null : type.toString());
+          client.getObjectFactory().newComplexValue(type == null ? null : type.toString());
 
       EdmComplexType edmType = null;
       if (client instanceof EdmEnabledODataClient && type != null) {
@@ -806,8 +811,8 @@ public class ODataBinderImpl implements ODataBinder {
                 : EdmPrimitiveTypeKind.valueOfFQN(type.toString())).
             build();
       } else if (valuable.isComplex()) {
-        final ODataComplexValue cValue = (ODataComplexValue) client.getObjectFactory().
-            newComplexValue(type == null ? null : type.toString());
+        final ODataComplexValue cValue =
+            client.getObjectFactory().newComplexValue(type == null ? null : type.toString());
 
         if (!valuable.isNull()) {
           EdmComplexType edmType = null;
@@ -853,8 +858,8 @@ public class ODataBinderImpl implements ODataBinder {
     final URI next = resource.getPayload().getNext();
 
     final ODataDelta delta = next == null
-        ? ((ODataClient) client).getObjectFactory().newDelta()
-        : ((ODataClient) client).getObjectFactory().newDelta(URIUtils.getURI(base, next.toASCIIString()));
+        ? client.getObjectFactory().newDelta()
+        : client.getObjectFactory().newDelta(URIUtils.getURI(base, next.toASCIIString()));
 
     if (resource.getPayload().getCount() != null) {
       delta.setCount(resource.getPayload().getCount());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
index 9afcb13..1b38732 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@ -158,18 +158,18 @@ public class ODataReaderImpl implements ODataReader {
   @Override
   public ODataEntitySet readEntitySet(final InputStream input, final ODataFormat format)
       throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
+    return client.getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
   }
 
   @Override
   public ODataEntity readEntity(final InputStream input, final ODataFormat format)
       throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
+    return client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
   }
 
   @Override
   public ODataProperty readProperty(final InputStream input, final ODataFormat format)
       throws ODataDeserializerException {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
+    return client.getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
index 79f1f07..cdb9020 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataWriterImpl.java
@@ -63,7 +63,7 @@ public class ODataWriterImpl implements ODataWriter {
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
-      IOUtils.closeQuietly(output);
+      IOUtils.closeQuietly(writer);
     }
   }
 
@@ -88,7 +88,7 @@ public class ODataWriterImpl implements ODataWriter {
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
-      IOUtils.closeQuietly(output);
+      IOUtils.closeQuietly(writer);
     }
   }
 
@@ -106,7 +106,7 @@ public class ODataWriterImpl implements ODataWriter {
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
-      IOUtils.closeQuietly(output);
+      IOUtils.closeQuietly(writer);
     }
   }
 
@@ -125,7 +125,7 @@ public class ODataWriterImpl implements ODataWriter {
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
-      IOUtils.closeQuietly(output);
+      IOUtils.closeQuietly(writer);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
index 43df061..151b466 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
@@ -229,8 +229,8 @@ public final class URIUtils {
                 : (obj instanceof Boolean)
                     ? BooleanUtils.toStringTrueFalse((Boolean) obj)
                     : (obj instanceof UUID)
-                        ?                            obj.toString()
-                            
+                        ? obj.toString()
+
                         : (obj instanceof byte[])
                             ? EdmBinary.getInstance().toUriLiteral(Hex.encodeHexString((byte[]) obj))
                             : (obj instanceof Timestamp)
@@ -264,7 +264,11 @@ public final class URIUtils {
       }
     } catch (Exception e) {
       LOG.warn("While escaping '{}', using toString()", obj, e);
-      value = obj.toString();
+      if (obj == null) {
+        value = "null";
+      } else {
+        value = obj.toString();
+      }
     }
 
     return value;
@@ -346,10 +350,8 @@ public final class URIUtils {
         value = param.getValue().asComplex().asJavaMap();
       } else if (param.getValue().isCollection()) {
         value = param.getValue().asCollection().asJavaCollection();
-      } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.ODataValue
-          && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
-
-        value = ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).asEnum().toString();
+      } else if (param.getValue().isEnum()) {
+        value = param.getValue().asEnum().toString();
       }
 
       inlineParams.append(URIUtils.escape(value)).append(',');

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index c5960a9..9935870 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -45,7 +45,6 @@ import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
 import org.junit.Ignore;
@@ -79,10 +78,10 @@ public class EntityTest extends AbstractTest {
     };
   }
 
-  private void singleton(final ODataFormat format) throws ODataDeserializerException {
+  private void singleton(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@@ -116,15 +115,16 @@ public class EntityTest extends AbstractTest {
 
     assertEquals(2, entity.getOperations().size());
     assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
-            entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress").getMetadataAnchor());
+        entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress").getMetadataAnchor());
     assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
-            entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress").getMetadataAnchor());
+        entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress").getMetadataAnchor());
 
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -137,10 +137,10 @@ public class EntityTest extends AbstractTest {
     singleton(ODataFormat.JSON_FULL_METADATA);
   }
 
-  private void withEnums(final ODataFormat format) throws ODataDeserializerException {
+  private void withEnums(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataProperty skinColor = entity.getProperty("SkinColor");
@@ -158,8 +158,9 @@ public class EntityTest extends AbstractTest {
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -172,11 +173,11 @@ public class EntityTest extends AbstractTest {
     withEnums(ODataFormat.JSON_FULL_METADATA);
   }
 
-  private void withInlineEntitySet(final ODataFormat format) throws ODataDeserializerException {
+  private void withInlineEntitySet(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream(
-            "Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
+        "Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataLink instruments = entity.getNavigationLink("MyPaymentInstruments");
@@ -192,8 +193,9 @@ public class EntityTest extends AbstractTest {
     // operations won't get serialized
     entity.getOperations().clear();
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -206,11 +208,11 @@ public class EntityTest extends AbstractTest {
     withInlineEntitySet(ODataFormat.JSON_FULL_METADATA);
   }
 
-  private void mediaEntity(final ODataFormat format) throws ODataDeserializerException {
+  private void mediaEntity(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream(
-            "Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
+        "Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertTrue(entity.isMediaEntity());
@@ -218,8 +220,9 @@ public class EntityTest extends AbstractTest {
     assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -232,10 +235,10 @@ public class EntityTest extends AbstractTest {
     mediaEntity(ODataFormat.JSON_FULL_METADATA);
   }
 
-  private void withStream(final ODataFormat format) throws ODataDeserializerException {
+  private void withStream(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertFalse(entity.isMediaEntity());
@@ -244,8 +247,9 @@ public class EntityTest extends AbstractTest {
     assertNotNull(editMedia);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -258,17 +262,18 @@ public class EntityTest extends AbstractTest {
     withStream(ODataFormat.JSON_FULL_METADATA);
   }
 
-  private void ref(final ODataFormat format) throws ODataDeserializerException {
+  private void ref(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertNotNull(entity.getId());
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -281,10 +286,10 @@ public class EntityTest extends AbstractTest {
     ref(ODataFormat.JSON);
   }
 
-  private void complexNavigationProperties(final ODataFormat format) throws ODataDeserializerException {
+  private void complexNavigationProperties(final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     final ODataComplexValue addressValue = entity.getProperty("Address").getComplexValue();
@@ -294,8 +299,9 @@ public class EntityTest extends AbstractTest {
     // ETag is not serialized
     entity.setETag(null);
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -308,10 +314,10 @@ public class EntityTest extends AbstractTest {
     complexNavigationProperties(ODataFormat.JSON);
   }
 
-  private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, ODataDeserializerException {
+  private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, Exception {
     final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format));
     final ODataEntity entity = getClient().getBinder().getODataEntity(
-            getClient().getDeserializer(format).toEntity(input));
+        getClient().getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertFalse(entity.getAnnotations().isEmpty());
@@ -329,18 +335,19 @@ public class EntityTest extends AbstractTest {
     assertTrue(annotation.hasComplexValue());
 
     final ODataLink orders = entity.getNavigationLink("Orders");
-    assertFalse(((org.apache.olingo.commons.api.domain.ODataLink) orders).getAnnotations().isEmpty());
+    assertFalse(orders.getAnnotations().isEmpty());
 
-    annotation = ((org.apache.olingo.commons.api.domain.ODataLink) orders).getAnnotations().get(0);
+    annotation = orders.getAnnotations().get(0);
     assertEquals("com.contoso.display.style", annotation.getTerm());
     assertEquals("com.contoso.display.styleType", annotation.getValue().getTypeName());
     assertTrue(annotation.hasComplexValue());
     assertEquals(2,
-            annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
+        annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
 
     final ODataEntity written = getClient().getBinder().getODataEntity(
-            new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
     assertEquals(entity, written);
+    input.close();
   }
 
   @Test
@@ -355,14 +362,15 @@ public class EntityTest extends AbstractTest {
     annotated(ODataFormat.JSON);
   }
 
-  private void derived(final ODataClient client, final ODataFormat format) throws ODataDeserializerException {
+  private void derived(final ODataClient client, final ODataFormat format) throws Exception {
     final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
     final ODataEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
     assertNotNull(entity);
 
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
     assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
-            ((ODataValuable) entity.getProperty("HomeAddress")).getValue().getTypeName());
+        ((ODataValuable) entity.getProperty("HomeAddress")).getValue().getTypeName());
+    input.close();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
index f8b91b1..9007626 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
@@ -29,47 +29,4 @@ public interface ODataProperty extends ODataInvokeResult, ODataAnnotatable, ODat
    * @return property name.
    */
   String getName();
-
-  /**
-   * Returns property value.
-   *
-   * @return property value.
-   */
-  ODataValue getValue();
-
-  /**
-   * Checks if has null value.
-   *
-   * @return 'TRUE' if has null value; 'FALSE' otherwise.
-   */
-  boolean hasNullValue();
-
-  /**
-   * Checks if has primitive value.
-   *
-   * @return 'TRUE' if has primitive value; 'FALSE' otherwise.
-   */
-  boolean hasPrimitiveValue();
-
-  /**
-   * Gets primitive value.
-   *
-   * @return primitive value if exists; null otherwise.
-   */
-  ODataPrimitiveValue getPrimitiveValue();
-
-  /**
-   * Checks if has collection value.
-   *
-   * @return 'TRUE' if has collection value; 'FALSE' otherwise.
-   */
-  boolean hasCollectionValue();
-
-  /**
-   * Checks if has complex value.
-   *
-   * @return 'TRUE' if has complex value; 'FALSE' otherwise.
-   */
-  boolean hasComplexValue();
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index b72cfec..3a91f49 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -203,7 +203,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
       }
     }
 
-    return new TypedOperand(((Property) currentProperty).getValue(), currentType, currentEdmProperty);
+    return new TypedOperand(currentProperty.getValue(), currentType, currentEdmProperty);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index 54a998c..382806c 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -315,7 +315,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     for (Object arrayElement : asCollection) {
       assertTrue(arrayElement instanceof ComplexValue);
-      List<Property> castedArrayElement = (List<Property>) ((ComplexValue) arrayElement).getValue();
+      List<Property> castedArrayElement = ((ComplexValue) arrayElement).getValue();
       assertEquals(2, castedArrayElement.size());
     }
   }
@@ -340,7 +340,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     Property complexProperty = entity.getProperty("PropertyComp");
     assertEquals(ValueType.COMPLEX, complexProperty.getValueType());
-    List<Property> complexPropertyValues = (List<Property>) complexProperty.asComplex().getValue();
+    List<Property> complexPropertyValues = complexProperty.asComplex().getValue();
     assertEquals(1, complexPropertyValues.size());
 
     Property property = entity.getProperty("CollPropertyComp");
@@ -352,7 +352,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
 
     for (Object arrayElement : asCollection) {
       assertTrue(arrayElement instanceof ComplexValue);
-      List<Property> castedArrayElement = (List<Property>) ((ComplexValue) arrayElement).getValue();
+      List<Property> castedArrayElement = ((ComplexValue) arrayElement).getValue();
       assertEquals(1, castedArrayElement.size());
     }
   }
@@ -513,8 +513,9 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     assertEquals("string", defProperty.getValue());
 
     Property complexProperty = entity.getProperty("PropertyCompMixedEnumDef");
-    List<Property> value = (List<Property>) complexProperty.asComplex().getValue();
+    List<Property> value = complexProperty.asComplex().getValue();
     assertEquals((short) 2, value.get(0).getValue());
+    stream.close();
   }
 
   @Test
@@ -577,7 +578,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
         new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
     List<?> collPropertyComp = entity.getProperty("CollPropertyComp").asCollection();
     assertNull(collPropertyComp.get(0));
-    List<Property> complexPropertyProperties = (List<Property>) ((ComplexValue) collPropertyComp.get(1)).getValue();
+    List<Property> complexPropertyProperties = ((ComplexValue) collPropertyComp.get(1)).getValue();
     assertEquals(Short.valueOf((short) 789), complexPropertyProperties.get(0).getValue());
     assertEquals("TEST 3", complexPropertyProperties.get(1).getValue());
   }


[2/2] olingo-odata4 git commit: [OLINGO-575] Delete unnecessary casts

Posted by ch...@apache.org.
[OLINGO-575] Delete unnecessary casts


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f4636407
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f4636407
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f4636407

Branch: refs/heads/master
Commit: f46364072a68eb040959bd289b3bbd608ced7f68
Parents: 9a666bd
Author: Christian Amend <ch...@apache.org>
Authored: Fri Mar 6 18:21:02 2015 +0100
Committer: Christian Amend <ch...@apache.org>
Committed: Fri Mar 6 18:21:02 2015 +0100

----------------------------------------------------------------------
 .../AbstractCollectionInvocationHandler.java    |   5 +-
 ...stractEntityCollectionInvocationHandler.java |   7 +-
 .../commons/AbstractPersistenceManager.java     |  22 +-
 .../AbstractStructuredInvocationHandler.java    |   2 +-
 .../commons/AnnotatableInvocationHandler.java   |  62 +++---
 .../proxy/commons/EntityInvocationHandler.java  |  12 +-
 .../commons/EntitySetInvocationHandler.java     |   5 +-
 .../olingo/ext/proxy/utils/CoreUtils.java       |  35 ++--
 .../olingo/fit/AbstractBaseTestITCase.java      |  32 +--
 .../proxy/v4/demo/odatademo/types/Customer.java |   6 +-
 .../fit/v4/JSONFormatConformanceTestITCase.java |   2 +-
 .../request/batch/BatchRequestFactoryImpl.java  |   3 +-
 .../request/cud/CUDRequestFactoryImpl.java      |   1 +
 .../invoke/AbstractODataInvokeRequest.java      |   8 +-
 .../request/retrieve/ODataDeltaRequestImpl.java |  25 ++-
 .../retrieve/RetrieveRequestFactoryImpl.java    |   5 +-
 .../retrieve/XMLMetadataRequestImpl.java        |  48 ++---
 .../olingo/client/core/edm/EdmClientImpl.java   | 206 +++++++++----------
 .../client/core/edm/EdmComplexTypeImpl.java     |  36 ++--
 .../client/core/edm/EdmEntityContainerImpl.java |  89 +++-----
 .../client/core/edm/EdmEntityTypeImpl.java      |  17 +-
 .../client/core/edm/EdmParameterImpl.java       |  25 +--
 .../olingo/client/core/edm/EdmPropertyImpl.java |  24 +--
 .../olingo/client/core/edm/EdmSchemaImpl.java   | 100 ++++-----
 .../core/edm/EdmStructuredTypeHelperImpl.java   |  19 +-
 .../client/core/edm/xml/ComplexTypeImpl.java    |   4 +-
 .../client/core/edm/xml/EntityTypeImpl.java     |   4 +-
 .../client/core/edm/xml/XMLMetadataImpl.java    |   2 +-
 .../http/ProxyWrappingHttpClientFactory.java    |   1 +
 .../ClientODataDeserializerImpl.java            |   4 +
 .../core/serialization/ODataBinderImpl.java     |  49 +++--
 .../core/serialization/ODataReaderImpl.java     |   6 +-
 .../core/serialization/ODataWriterImpl.java     |   8 +-
 .../apache/olingo/client/core/uri/URIUtils.java |  16 +-
 .../olingo/client/core/v4/EntityTest.java       |  90 ++++----
 .../commons/api/domain/ODataProperty.java       |  43 ----
 .../expression/ExpressionVisitorImpl.java       |   2 +-
 .../json/ODataJsonDeserializerEntityTest.java   |  11 +-
 38 files changed, 454 insertions(+), 582 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
index 9cc6a25..3f75544 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
@@ -36,7 +36,6 @@ import org.apache.olingo.client.api.uri.QueryOption;
 import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.client.api.uri.URIFilter;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.ext.proxy.AbstractService;
 import org.apache.olingo.ext.proxy.api.AbstractTerm;
 import org.apache.olingo.ext.proxy.api.EntityType;
@@ -182,7 +181,7 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
   public <ET extends EntityType<?>> boolean addRef(final ET element) {
     if (element instanceof Proxy && Proxy.getInvocationHandler(element) instanceof EntityInvocationHandler) {
       final EntityInvocationHandler handler = EntityInvocationHandler.class.cast(Proxy.getInvocationHandler(element));
-      final URI id = ((ODataEntity) handler.getEntity()).getId();
+      final URI id = handler.getEntity().getId();
       if (id == null) {
         return false;
       }
@@ -195,7 +194,7 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
   }
 
   public void refs() {
-      ((URIBuilder) this.uri).appendRefSegment();
+       this.uri.appendRefSegment();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
index b5a9524..01e5843 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractEntityCollectionInvocationHandler.java
@@ -33,6 +33,7 @@ import org.apache.olingo.client.api.uri.URIBuilder;
 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 org.apache.olingo.commons.api.domain.ODataSingleton;
 import org.apache.olingo.ext.proxy.AbstractService;
 import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 import org.apache.olingo.ext.proxy.api.AbstractSingleton;
@@ -100,7 +101,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<T extends Entity
     final List<ODataAnnotation> anns = new ArrayList<ODataAnnotation>();
 
     if (isSingleton) {
-      final ODataRetrieveResponse<org.apache.olingo.commons.api.domain.ODataSingleton> res =
+      final ODataRetrieveResponse<ODataSingleton> res =
           ((ODataClient) getClient()).getRetrieveRequestFactory().getSingletonRequest(uri).execute();
 
       entities.add(res.getBody());
@@ -115,9 +116,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<T extends Entity
       final ODataEntitySet entitySet = res.getBody();
       entities.addAll(entitySet.getEntities());
       next = entitySet.getNext();
-      if (entitySet instanceof ODataEntitySet) {
-        anns.addAll(((ODataEntitySet) entitySet).getAnnotations());
-      }
+      anns.addAll(entitySet.getAnnotations());
     }
 
     final List<T> res = new ArrayList<T>(entities.size());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
index c20ad25..9081875 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
@@ -156,14 +156,12 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
       entity.getProperties().clear();
       CoreUtils.addProperties(service.getClient(), handler.getPropertyChanges(), entity);
 
-      if (entity instanceof ODataEntity) {
-        ((ODataEntity) entity).getAnnotations().clear();
-        CoreUtils.addAnnotations(service.getClient(), handler.getAnnotations(), (ODataEntity) entity);
+      entity.getAnnotations().clear();
+      CoreUtils.addAnnotations(service.getClient(), handler.getAnnotations(), entity);
 
-        for (Map.Entry<String, AnnotatableInvocationHandler> entry : handler.getPropAnnotatableHandlers().entrySet()) {
-          CoreUtils.addAnnotations(service.getClient(),
-              entry.getValue().getAnnotations(), ((ODataEntity) entity).getProperty(entry.getKey()));
-        }
+      for (Map.Entry<String, AnnotatableInvocationHandler> entry : handler.getPropAnnotatableHandlers().entrySet()) {
+        CoreUtils.addAnnotations(service.getClient(),
+            entry.getValue().getAnnotations(), entity.getProperty(entry.getKey()));
       }
     }
 
@@ -235,13 +233,11 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
       }
     }
 
-    if (entity instanceof ODataEntity) {
-      for (Map.Entry<String, AnnotatableInvocationHandler> entry : handler.getNavPropAnnotatableHandlers().entrySet()) {
+    for (Map.Entry<String, AnnotatableInvocationHandler> entry : handler.getNavPropAnnotatableHandlers().entrySet()) {
 
-        CoreUtils.addAnnotations(service.getClient(),
-            entry.getValue().getAnnotations(),
-            (org.apache.olingo.commons.api.domain.ODataLink) entity.getNavigationLink(entry.getKey()));
-      }
+      CoreUtils.addAnnotations(service.getClient(),
+          entry.getValue().getAnnotations(),
+          entity.getNavigationLink(entry.getKey()));
     }
 
     final AttachedEntityStatus processedStatus = queue(handler, entity, changeset);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
index 074dc3f..e1b735e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
@@ -633,7 +633,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
   }
 
   public void refs() {
-      ((URIBuilder) this.uri).appendRefSegment();
+      this.uri.appendRefSegment();
   }
 
   public void clearQueryOptions() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
index 16ef932..9da95ff 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -51,14 +51,14 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
   private final AbstractStructuredInvocationHandler targetHandler;
 
   private final Map<Class<? extends AbstractTerm>, Object> annotations =
-          new HashMap<Class<? extends AbstractTerm>, Object>();
+      new HashMap<Class<? extends AbstractTerm>, Object>();
 
   public AnnotatableInvocationHandler(
-          final AbstractService<?> service,
-          final String propName,
-          final String navPropName,
-          final EntityInvocationHandler entityHandler,
-          final AbstractStructuredInvocationHandler targetHandler) {
+      final AbstractService<?> service,
+      final String propName,
+      final String navPropName,
+      final EntityInvocationHandler entityHandler,
+      final AbstractStructuredInvocationHandler targetHandler) {
 
     super(service);
 
@@ -78,20 +78,16 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
   }
 
   private List<ODataAnnotation> internalAnnotations() {
-    List<ODataAnnotation> result = Collections.<ODataAnnotation>emptyList();
-
-    if (entityHandler.getEntity() instanceof ODataEntity) {
-      if (targetHandler.getInternal() instanceof ODataEntity) {
-        result = propName == null
-                ? ((org.apache.olingo.commons.api.domain.ODataLink) ((ODataEntity) targetHandler.getInternal()).
-                getNavigationLink(navPropName)).getAnnotations()
-                : ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
-      } else if (targetHandler.getInternal() instanceof ODataComplexValue) {
-        result = propName == null
-                ? ((org.apache.olingo.commons.api.domain.ODataLink) ((ODataComplexValue) targetHandler.
-                getInternal()).getNavigationLink(navPropName)).getAnnotations()
-                : ((ODataComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
-      }
+    List<ODataAnnotation> result = Collections.<ODataAnnotation> emptyList();
+
+    if (targetHandler.getInternal() instanceof ODataEntity) {
+      result = propName == null
+          ? ((ODataEntity) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
+          : ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
+    } else if (targetHandler.getInternal() instanceof ODataComplexValue) {
+      result = propName == null
+          ? ((ODataComplexValue) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
+          : ((ODataComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
     }
 
     return result;
@@ -113,7 +109,7 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
         if (item instanceof Proxy) {
           final InvocationHandler handler = Proxy.getInvocationHandler(item);
           if ((handler instanceof ComplexInvocationHandler)
-                  && ((ComplexInvocationHandler) handler).getEntityHandler() == null) {
+              && ((ComplexInvocationHandler) handler).getEntityHandler() == null) {
             ((ComplexInvocationHandler) handler).setEntityHandler(entityHandler);
           }
         }
@@ -146,7 +142,7 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
 
     if (annotations.containsKey(term)) {
       res = annotations.get(term);
-    } else if (entityHandler.getEntity() instanceof ODataEntity) {
+    } else {
       try {
         final Term termAnn = term.getAnnotation(Term.class);
         final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
@@ -157,8 +153,8 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
           }
         }
         res = annotation == null || annotation.hasNullValue()
-                ? null
-                : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, targetHandler.service);
+            ? null
+            : CoreUtils.getObjectFromODataValue(annotation.getValue(), null, targetHandler.service);
         if (res != null) {
           annotations.put(term, res);
         }
@@ -172,8 +168,6 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
 
   @Override
   public Collection<Class<? extends AbstractTerm>> readAnnotationTerms() {
-    return entityHandler.getEntity() instanceof ODataEntity
-            ? CoreUtils.getAnnotationTerms(service, internalAnnotations())
-            : Collections.<Class<? extends AbstractTerm>>emptyList();
+    return CoreUtils.getAnnotationTerms(service, internalAnnotations());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index d8c099e..20ab3a5 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -410,12 +410,12 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
 
     if (annotations.containsKey(term)) {
       res = annotations.get(term);
-    } else if (getEntity() instanceof ODataEntity) {
+    } else {
       try {
         final Term termAnn = term.getAnnotation(Term.class);
         final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
         ODataAnnotation annotation = null;
-        for (ODataAnnotation _annotation : ((ODataEntity) getEntity()).getAnnotations()) {
+        for (ODataAnnotation _annotation : getEntity().getAnnotations()) {
           if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) {
             annotation = _annotation;
           }
@@ -436,9 +436,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
 
   @Override
   public Collection<Class<? extends AbstractTerm>> readAnnotationTerms() {
-    return getEntity() instanceof ODataEntity
-        ? CoreUtils.getAnnotationTerms(service, ((ODataEntity) getEntity()).getAnnotations())
-        : Collections.<Class<? extends AbstractTerm>> emptyList();
+    return CoreUtils.getAnnotationTerms(service, getEntity().getAnnotations());
   }
 
   @Override
@@ -450,7 +448,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
       final ODataEntityRequest<ODataEntity> req =
           getClient().getRetrieveRequestFactory().getEntityRequest(uri.build());
 
-        req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
+      req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
 
       final ODataRetrieveResponse<ODataEntity> res = req.execute();
 
@@ -492,7 +490,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
 
   // use read- instead of get- for .invoke() to distinguish it from entity property getter.
   public String readEntityReferenceID() {
-    URI id = getEntity() == null ? null : ((ODataEntity) getEntity()).getId();
+    URI id = getEntity() == null ? null : getEntity().getId();
 
     return id == null ? null : id.toASCIIString();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index 2cb9226..6b7ff9c 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
@@ -28,7 +28,6 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
 import org.apache.commons.lang3.tuple.Triple;
-import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
 import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
@@ -196,14 +195,14 @@ public class EntitySetInvocationHandler<
 
   @Override
   public Search<T, EC> createSearch() {
-    return new SearchImpl<T, EC>((EdmEnabledODataClient) getClient(), this.collItemRef, this.baseURI, this);
+    return new SearchImpl<T, EC>(getClient(), this.collItemRef, this.baseURI, this);
   }
 
   @Override
   @SuppressWarnings("unchecked")
   public <S extends T, SEC extends EntityCollection<S, ?, ?>> Search<S, SEC> createSearch(final Class<SEC> reference) {
     return new SearchImpl<S, SEC>(
-            (EdmEnabledODataClient) getClient(),
+            getClient(),
             reference,
             baseURI,
             (EntitySetInvocationHandler<S, ?, SEC>) this);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
index bfec4ea..4bb75ff 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
@@ -46,7 +46,6 @@ import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEnumValue;
 import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
@@ -106,8 +105,7 @@ public final class CoreUtils {
         if (intType.isPrimitiveType()) {
           value.asCollection().add(getODataValue(client, intType, collectionItem).asPrimitive());
         } else if (intType.isEnumType()) {
-          value.asCollection().add(((org.apache.olingo.commons.api.domain.ODataValue) getODataValue(
-              client, intType, collectionItem)).asEnum());
+          value.asCollection().add((getODataValue(client, intType, collectionItem)).asEnum());
         } else if (intType.isComplexType()) {
           value.asCollection().add(getODataValue(client, intType, collectionItem).asComplex());
         } else {
@@ -139,8 +137,7 @@ public final class CoreUtils {
       }
 
     } else if (type.isEnumType()) {
-      value = ((org.apache.olingo.commons.api.domain.ODataObjectFactory) client.getObjectFactory()).
-          newEnumValue(type.getFullQualifiedName().toString(), ((Enum<?>) obj).name());
+      value = client.getObjectFactory().newEnumValue(type.getFullQualifiedName().toString(), ((Enum<?>) obj).name());
     } else {
       value = client.getObjectFactory().newPrimitiveValueBuilder().setType(type.getPrimitiveTypeKind()).setValue(obj).
           build();
@@ -204,8 +201,7 @@ public final class CoreUtils {
           : new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).
               setTypeExpression(type.getFullQualifiedName().toString()).build();
 
-      annotation = new ODataAnnotationImpl(term,
-          (org.apache.olingo.commons.api.domain.ODataValue) getODataValue(client, valueType, obj));
+      annotation = new ODataAnnotationImpl(term, getODataValue(client, valueType, obj));
     }
 
     return annotation;
@@ -232,8 +228,7 @@ public final class CoreUtils {
         } else if (valueType.isComplexType()) {
           property = client.getObjectFactory().newComplexProperty(name, value.asComplex());
         } else if (valueType.isEnumType()) {
-          property = ((ODataObjectFactory) client.getObjectFactory()).newEnumProperty(name,
-              ((org.apache.olingo.commons.api.domain.ODataValue) value).asEnum());
+          property = client.getObjectFactory().newEnumProperty(name, value.asEnum());
         } else {
           throw new UnsupportedOperationException("Usupported object type " + valueType.getFullQualifiedName());
         }
@@ -273,15 +268,15 @@ public final class CoreUtils {
     EdmPrimitiveTypeKind bckCandidate = null;
 
     for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) {
-        final Class<?> target = EdmPrimitiveTypeFactory.getInstance(kind).getDefaultType();
-
-        if (clazz.equals(target)) {
-          return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(kind.toString()).build();
-        } else if (target.isAssignableFrom(clazz)) {
-          bckCandidate = kind;
-        } else if (target == Timestamp.class && kind == EdmPrimitiveTypeKind.DateTimeOffset) {
-          bckCandidate = kind;
-        }
+      final Class<?> target = EdmPrimitiveTypeFactory.getInstance(kind).getDefaultType();
+
+      if (clazz.equals(target)) {
+        return new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(kind.toString()).build();
+      } else if (target.isAssignableFrom(clazz)) {
+        bckCandidate = kind;
+      } else if (target == Timestamp.class && kind == EdmPrimitiveTypeKind.DateTimeOffset) {
+        bckCandidate = kind;
+      }
     }
 
     if (bckCandidate == null) {
@@ -297,8 +292,8 @@ public final class CoreUtils {
       final ODataEntity entity) {
 
     for (Map.Entry<String, Object> entry : changes.entrySet()) {
-      ((List<ODataProperty>) entity.getProperties()).add(
-          getODataEntityProperty(client, entity.getTypeName(), entry.getKey(), entry.getValue()));
+      entity.getProperties()
+          .add(getODataEntityProperty(client, entity.getTypeName(), entry.getKey(), entry.getValue()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index 64ed4eb..baadf20 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -1,18 +1,18 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -73,7 +73,9 @@ public abstract class AbstractBaseTestITCase {
       final StringWriter writer = new StringWriter();
       try {
         getClient().getSerializer(ODataFormat.JSON).write(writer, entity);
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        // Debug
+      }
       writer.flush();
       LOG.debug(message + "\n{}", writer.toString());
     }
@@ -84,7 +86,9 @@ public abstract class AbstractBaseTestITCase {
       final StringWriter writer = new StringWriter();
       try {
         getClient().getSerializer(ODataFormat.JSON).write(writer, entitySet);
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        // Debug
+      }
       writer.flush();
       LOG.debug(message + "\n{}", writer.toString());
     }
@@ -103,14 +107,18 @@ public abstract class AbstractBaseTestITCase {
       StringWriter writer = new StringWriter();
       try {
         getClient().getSerializer(ODataFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        // Debug
+      }
       writer.flush();
       LOG.debug(message + " (Atom)\n{}", writer.toString());
 
       writer = new StringWriter();
       try {
         getClient().getSerializer(ODataFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
-      } catch (final ODataSerializerException e) {}
+      } catch (final ODataSerializerException e) {
+        // Debug
+      }
       writer.flush();
       LOG.debug(message + " (JSON)\n{}", writer.toString());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/types/Customer.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/types/Customer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/types/Customer.java
index ec046d1..a93e04a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/types/Customer.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/demo/odatademo/types/Customer.java
@@ -72,8 +72,9 @@ public interface Customer
                 fcNSPrefix = "",
                 fcNSURI = "",
                 fcKeepInContent = false)
+    @Override
     java.lang.Integer getID();
-
+    @Override
     void setID(java.lang.Integer _iD);
     
     
@@ -95,8 +96,9 @@ public interface Customer
                 fcNSPrefix = "",
                 fcNSURI = "",
                 fcKeepInContent = false)
+    @Override
     java.lang.String getName();
-
+    @Override
     void setName(java.lang.String _name);
     
     

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
index e1e1edf..b7a65e8 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
@@ -299,7 +299,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
     assertEquals(Boolean.TRUE, style.getComplexValue().get("title").getPrimitiveValue().toCastValue(Boolean.class));
     assertEquals(1, style.getComplexValue().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
 
-    final ODataLink orders = (ODataLink) entity.getNavigationLink("Orders");
+    final ODataLink orders = entity.getNavigationLink("Orders");
     assertEquals(1, orders.getAnnotations().size());
 
     final ODataAnnotation style2 = orders.getAnnotations().get(0);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/BatchRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/BatchRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/BatchRequestFactoryImpl.java
index b25034a..5ce3b8b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/BatchRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/BatchRequestFactoryImpl.java
@@ -32,7 +32,6 @@ public class BatchRequestFactoryImpl implements BatchRequestFactory {
 
   @Override
   public ODataBatchRequest getBatchRequest(final String serviceRoot) {
-    return new ODataBatchRequestImpl(
-        (ODataClient) client, client.newURIBuilder(serviceRoot).appendBatchSegment().build());
+    return new ODataBatchRequestImpl(client, client.newURIBuilder(serviceRoot).appendBatchSegment().build());
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/CUDRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/CUDRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/CUDRequestFactoryImpl.java
index 89a0449..75c3076 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/CUDRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/CUDRequestFactoryImpl.java
@@ -245,6 +245,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
     return new ODataReferenceAddingRequestImpl(client, HttpMethod.POST, targetURI, wrappedPayload);
   }
 
+  @Override
   public ODataReferenceAddingRequest getReferenceSingleChangeRequest(final URI serviceRoot, final URI targetURI,
       final URI reference) {
     // See OData Protocol 11.4.6.3

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 6bf3282..e9801cc 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -126,12 +126,8 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
         } else if (param.getValue().isCollection()) {
           property = odataClient.getObjectFactory().
               newCollectionProperty(param.getKey(), param.getValue().asCollection());
-        } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.ODataValue
-            && ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).isEnum()) {
-
-          property = ((ODataClient) odataClient).getObjectFactory().
-              newEnumProperty(param.getKey(),
-                  ((org.apache.olingo.commons.api.domain.ODataValue) param.getValue()).asEnum());
+        } else if (param.getValue().isEnum()) {
+          property = odataClient.getObjectFactory().newEnumProperty(param.getKey(), param.getValue().asEnum());
         }
 
         if (property != null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
index bb3ccd9..e01da68 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataDeltaRequestImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -34,7 +34,7 @@ import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
 
 public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDelta>
-        implements ODataDeltaRequest {
+    implements ODataDeltaRequest {
 
   public ODataDeltaRequestImpl(final ODataClient odataClient, final URI query) {
     super(odataClient, query);
@@ -56,7 +56,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDel
     private ODataDelta delta = null;
 
     private ODataDeltaResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
-            final HttpResponse res) {
+        final HttpResponse res) {
 
       super(odataClient, httpClient, res);
     }
@@ -65,11 +65,10 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ODataDel
     public ODataDelta getBody() {
       if (delta == null) {
         try {
-          final ResWrap<Delta> resource = ((ODataClient) odataClient).
-                  getDeserializer(ODataFormat.fromString(getContentType())).
-                  toDelta(res.getEntity().getContent());
+          final ResWrap<Delta> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
+              toDelta(res.getEntity().getContent());
 
-          delta = ((ODataClient) odataClient).getBinder().getODataDelta(resource);
+          delta = odataClient.getBinder().getODataDelta(resource);
         } catch (IOException e) {
           throw new HttpClientException(e);
         } catch (final ODataDeserializerException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestFactoryImpl.java
index 6b179ae..f765875 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/RetrieveRequestFactoryImpl.java
@@ -43,7 +43,7 @@ import org.apache.olingo.commons.api.domain.ODataSingleton;
 public class RetrieveRequestFactoryImpl implements RetrieveRequestFactory {
 
   protected final ODataClient client;
-  
+
   public RetrieveRequestFactoryImpl(final ODataClient client) {
     this.client = client;
   }
@@ -89,8 +89,7 @@ public class RetrieveRequestFactoryImpl implements RetrieveRequestFactory {
 
   @Override
   public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) {
-    return new XMLMetadataRequestImpl(((ODataClient) client),
-        client.newURIBuilder(serviceRoot).appendMetadataSegment().build());
+    return new XMLMetadataRequestImpl(client, client.newURIBuilder(serviceRoot).appendMetadataSegment().build());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java
index 1f41887..97c55e0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -39,8 +39,8 @@ import org.apache.olingo.client.core.edm.xml.SchemaImpl;
 import org.apache.olingo.commons.api.format.ODataFormat;
 
 public class XMLMetadataRequestImpl
-        extends AbstractMetadataRequestImpl<XMLMetadata>
-        implements XMLMetadataRequest {
+    extends AbstractMetadataRequestImpl<XMLMetadata>
+    implements XMLMetadataRequest {
 
   XMLMetadataRequestImpl(final ODataClient odataClient, final URI uri) {
     super(odataClient, uri);
@@ -48,18 +48,18 @@ public class XMLMetadataRequestImpl
 
   @Override
   public ODataRetrieveResponse<XMLMetadata> execute() {
-    final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri, null);
+    final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl(odataClient, uri, null);
     final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
 
     final XMLMetadataResponseImpl response =
-            new XMLMetadataResponseImpl(odataClient, httpClient, rootReq.getHttpResponse(), rootRes.getBody());
+        new XMLMetadataResponseImpl(odataClient, httpClient, rootReq.getHttpResponse(), rootRes.getBody());
 
     // process external references
     for (Reference reference : rootRes.getBody().getReferences()) {
       final SingleXMLMetadatRequestImpl includeReq = new SingleXMLMetadatRequestImpl(
-              (ODataClient) odataClient,
-              odataClient.newURIBuilder(uri.resolve(reference.getUri()).toASCIIString()).build(),
-              uri);
+          odataClient,
+          odataClient.newURIBuilder(uri.resolve(reference.getUri()).toASCIIString()).build(),
+          uri);
       final XMLMetadata includeMetadata = includeReq.execute().getBody();
 
       // edmx:Include
@@ -86,10 +86,10 @@ public class XMLMetadataRequestImpl
             // take into account only when (TargetNamespace was either not provided or matches) and
             // (Qualifier was either not provided or matches)
             if ((StringUtils.isBlank(include.getTargetNamespace())
-                    || include.getTargetNamespace().equals(
-                            StringUtils.substringBeforeLast(annotationGroup.getTarget(), ".")))
-                    && (StringUtils.isBlank(include.getQualifier())
-                    || include.getQualifier().equals(annotationGroup.getQualifier()))) {
+                || include.getTargetNamespace().equals(
+                StringUtils.substringBeforeLast(annotationGroup.getTarget(), ".")))
+                && (StringUtils.isBlank(include.getQualifier())
+                || include.getQualifier().equals(annotationGroup.getQualifier()))) {
 
               final AnnotationsImpl toBeIncluded = new AnnotationsImpl();
               toBeIncluded.setTarget(annotationGroup.getTarget());
@@ -128,9 +128,11 @@ public class XMLMetadataRequestImpl
       return httpResponse;
     }
 
-    /** Referenced document's URIs must only have the same scheme, host, and port as the
-     *  main metadata document's URI but don't have to start with the service root
-     *  as all other OData request URIs. */
+    /**
+     * Referenced document's URIs must only have the same scheme, host, and port as the
+     * main metadata document's URI but don't have to start with the service root
+     * as all other OData request URIs.
+     */
     @Override
     protected void checkRequest(final ODataClient odataClient, final HttpUriRequest request) {
       if (parentURI == null) {
@@ -157,7 +159,7 @@ public class XMLMetadataRequestImpl
         public XMLMetadata getBody() {
           if (metadata == null) {
             try {
-              metadata = ((ODataClient) odataClient).getDeserializer(ODataFormat.XML).toMetadata(getRawResponse());
+              metadata = odataClient.getDeserializer(ODataFormat.XML).toMetadata(getRawResponse());
             } finally {
               this.close();
             }
@@ -173,7 +175,7 @@ public class XMLMetadataRequestImpl
     private final XMLMetadata metadata;
 
     private XMLMetadataResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
-            final HttpResponse res, final XMLMetadata metadata) {
+        final HttpResponse res, final XMLMetadata metadata) {
 
       super(odataClient, httpClient, null);
       this.metadata = metadata;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
index f608984..31a7384 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -95,7 +95,7 @@ public class EdmClientImpl extends AbstractEdm {
   protected Map<String, EdmSchema> createSchemas() {
     final Map<String, EdmSchema> _schemas = new LinkedHashMap<String, EdmSchema>(xmlSchemas.size());
     for (Schema schema : xmlSchemas) {
-      _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, xmlSchemas, schema));
+      _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, schema));
     }
     return _schemas;
   }
@@ -108,7 +108,7 @@ public class EdmClientImpl extends AbstractEdm {
     if (schema != null) {
       final EntityContainer xmlEntityContainer = schema.getDefaultEntityContainer();
       if (xmlEntityContainer != null) {
-        result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer, xmlSchemas);
+        result = new EdmEntityContainerImpl(this, containerName, xmlEntityContainer);
       }
     }
 
@@ -135,14 +135,13 @@ public class EdmClientImpl extends AbstractEdm {
     EdmTypeDefinition result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(typeDefinitionName.getNamespace());
-    if (schema instanceof Schema) {
-      final TypeDefinition xmlTypeDefinition = ((Schema) schema).
-              getTypeDefinition(typeDefinitionName.getName());
+    if (schema != null) {
+      final TypeDefinition xmlTypeDefinition = schema.
+          getTypeDefinition(typeDefinitionName.getName());
       if (xmlTypeDefinition != null) {
         result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition);
       }
     }
-
     return result;
   }
 
@@ -154,7 +153,7 @@ public class EdmClientImpl extends AbstractEdm {
     if (schema != null) {
       final EntityType xmlEntityType = schema.getEntityType(entityTypeName.getName());
       if (xmlEntityType != null) {
-        result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlSchemas, xmlEntityType);
+        result = EdmEntityTypeImpl.getInstance(this, entityTypeName, xmlEntityType);
       }
     }
 
@@ -169,7 +168,7 @@ public class EdmClientImpl extends AbstractEdm {
     if (schema != null) {
       final ComplexType xmlComplexType = schema.getComplexType(complexTypeName.getName());
       if (xmlComplexType != null) {
-        result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlSchemas, xmlComplexType);
+        result = EdmComplexTypeImpl.getInstance(this, complexTypeName, xmlComplexType);
       }
     }
 
@@ -181,18 +180,16 @@ public class EdmClientImpl extends AbstractEdm {
     EdmAction result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
-    if (schema instanceof Schema) {
-      final List<Action> actions = ((Schema) schema).
-              getActions(actionName.getName());
-      boolean found = false;
-      for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
-        final Action action = itor.next();
-        if (!action.isBound()) {
-          found = true;
-          result = EdmActionImpl.getInstance(this, actionName, action);
-        }
+    final List<Action> actions = schema.
+        getActions(actionName.getName());
+    boolean found = false;
+    for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
+      final Action action = itor.next();
+      if (!action.isBound()) {
+        found = true;
+        result = EdmActionImpl.getInstance(this, actionName, action);
       }
-    } 
+    }
     return result;
   }
 
@@ -201,16 +198,14 @@ public class EdmClientImpl extends AbstractEdm {
     final List<EdmFunction> result = new ArrayList<EdmFunction>();
 
     final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
-    if (schema instanceof Schema) {
-      final List<Function> functions = ((Schema) schema).
-              getFunctions(functionName.getName());
-      for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) {
-        final Function function = itor.next();
-        if (!function.isBound()) {
-          result.add(EdmFunctionImpl.getInstance(this, functionName, function));
-        }
+    final List<Function> functions = schema.
+        getFunctions(functionName.getName());
+    for (final Iterator<Function> itor = functions.iterator(); itor.hasNext();) {
+      final Function function = itor.next();
+      if (!function.isBound()) {
+        result.add(EdmFunctionImpl.getInstance(this, functionName, function));
       }
-    } 
+    }
     return result;
   }
 
@@ -219,89 +214,83 @@ public class EdmClientImpl extends AbstractEdm {
     EdmFunction result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
-    if (schema instanceof Schema) {
-      final List<Function> functions = ((Schema) schema).
-              getFunctions(functionName.getName());
-      boolean found = false;
-      for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
-        final Function function = itor.next();
-        if (!function.isBound()) {
-          final Set<String> functionParamNames = new HashSet<String>();
-          for (Parameter param : function.getParameters()) {
-            functionParamNames.add(param.getName());
-          }
-          found = parameterNames == null
-                  ? functionParamNames.isEmpty()
-                  : functionParamNames.containsAll(parameterNames);
-          result = EdmFunctionImpl.getInstance(this, functionName, function);
+    final List<Function> functions = schema.
+        getFunctions(functionName.getName());
+    boolean found = false;
+    for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
+      final Function function = itor.next();
+      if (!function.isBound()) {
+        final Set<String> functionParamNames = new HashSet<String>();
+        for (Parameter param : function.getParameters()) {
+          functionParamNames.add(param.getName());
         }
+        found = parameterNames == null
+            ? functionParamNames.isEmpty()
+            : functionParamNames.containsAll(parameterNames);
+        result = EdmFunctionImpl.getInstance(this, functionName, function);
       }
-    } 
+    }
     return result;
   }
 
   @Override
   protected EdmAction createBoundAction(final FullQualifiedName actionName,
-          final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
+      final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) {
 
     EdmAction result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(actionName.getNamespace());
-    if (schema instanceof Schema) {
-      final List<Action> actions =
-              ((Schema) schema).getActions(actionName.getName());
-      boolean found = false;
-      for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
-        final Action action = itor.next();
-        if (action.isBound()) {
-          final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
-                  setTypeExpression(action.getParameters().get(0).getType()).build();
-          if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
-                  && (isBindingParameterCollection == null
-                  || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
-
-            found = true;
-            result = EdmActionImpl.getInstance(this, actionName, action);
-          }
+    final List<Action> actions =
+        schema.getActions(actionName.getName());
+    boolean found = false;
+    for (final Iterator<Action> itor = actions.iterator(); itor.hasNext() && !found;) {
+      final Action action = itor.next();
+      if (action.isBound()) {
+        final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
+            setTypeExpression(action.getParameters().get(0).getType()).build();
+        if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+            && (isBindingParameterCollection == null
+            || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
+
+          found = true;
+          result = EdmActionImpl.getInstance(this, actionName, action);
         }
       }
-    } 
+    }
     return result;
   }
 
   @Override
   protected EdmFunction createBoundFunction(final FullQualifiedName functionName,
-          final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
-          final List<String> parameterNames) {
+      final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection,
+      final List<String> parameterNames) {
 
     EdmFunction result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(functionName.getNamespace());
-    if (schema instanceof Schema) {
-      final List<Function> functions = ((Schema) schema).
-              getFunctions(functionName.getName());
-      boolean found = false;
-      for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
-        final Function function = itor.next();
-        if (function.isBound()) {
-          final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
-                  setTypeExpression(function.getParameters().get(0).getType()).build();
-          if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
-                  && (isBindingParameterCollection == null
-                  || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
-
-            final Set<String> functionParamNames = new HashSet<String>();
-            for (Parameter param : function.getParameters()) {
-              functionParamNames.add(param.getName());
-            }
-            found = parameterNames == null
-                    ? functionParamNames.isEmpty()
-                    : functionParamNames.containsAll(parameterNames);
-            result = EdmFunctionImpl.getInstance(this, functionName, function);
+    final List<Function> functions = schema.
+        getFunctions(functionName.getName());
+    boolean found = false;
+    for (final Iterator<Function> itor = functions.iterator(); itor.hasNext() && !found;) {
+      final Function function = itor.next();
+      if (function.isBound()) {
+        final EdmTypeInfo boundParam = new EdmTypeInfo.Builder().setEdm(this).
+            setTypeExpression(function.getParameters().get(0).getType()).build();
+        if (bindingParameterTypeName.equals(boundParam.getFullQualifiedName())
+            && (isBindingParameterCollection == null
+            || isBindingParameterCollection.booleanValue() == boundParam.isCollection())) {
+
+          final Set<String> functionParamNames = new HashSet<String>();
+          for (Parameter param : function.getParameters()) {
+            functionParamNames.add(param.getName());
           }
+          found = parameterNames == null
+              ? functionParamNames.isEmpty()
+              : functionParamNames.containsAll(parameterNames);
+          result = EdmFunctionImpl.getInstance(this, functionName, function);
         }
       }
-    } 
+    }
     return result;
   }
 
@@ -310,13 +299,12 @@ public class EdmClientImpl extends AbstractEdm {
     EdmTerm result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(termName.getNamespace());
-    if (schema instanceof Schema) {
-      final Term term = ((Schema) schema).getTerm(termName.getName());
+    if (schema != null) {
+      final Term term = schema.getTerm(termName.getName());
       if (term != null) {
         result = new EdmTermImpl(this, schema.getNamespace(), term);
       }
     }
-
     return result;
   }
 
@@ -325,12 +313,10 @@ public class EdmClientImpl extends AbstractEdm {
     EdmAnnotationsImpl result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(targetName.getNamespace());
-    if (schema instanceof Schema) {
-      final Annotations annotationGroup =
-              ((Schema) schema).getAnnotationGroup(targetName.getName());
-      if (annotationGroup != null) {
-        result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup);
-      }
+    final Annotations annotationGroup =
+        schema.getAnnotationGroup(targetName.getName());
+    if (annotationGroup != null) {
+      result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup);
     }
 
     return result;
@@ -341,15 +327,13 @@ public class EdmClientImpl extends AbstractEdm {
     List<EdmAnnotation> result = null;
 
     final Schema schema = xmlSchemaByNamespace.get(annotatedName.getNamespace());
-    if (schema instanceof Schema) {
-      final Annotatable annotatable =
-              ((Schema) schema).getAnnotatables().get(annotatedName.getName());
-      if (annotatable != null && annotatable.getAnnotations() != null) {
-        result = new ArrayList<EdmAnnotation>();
-        for (Annotation annotation : annotatable.getAnnotations()) {
-          final EdmTerm term = getTerm(new FullQualifiedName(annotation.getTerm()));
-          result.add(new EdmAnnotationImpl(this, annotation));
-        }
+    final Annotatable annotatable =
+        schema.getAnnotatables().get(annotatedName.getName());
+    if (annotatable != null && annotatable.getAnnotations() != null) {
+      result = new ArrayList<EdmAnnotation>();
+      for (Annotation annotation : annotatable.getAnnotations()) {
+        final EdmTerm term = getTerm(new FullQualifiedName(annotation.getTerm()));
+        result.add(new EdmAnnotationImpl(this, annotation));
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
index e734200..d985110 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.olingo.client.api.edm.xml.ComplexType;
-import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmAnnotation;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
@@ -41,29 +40,24 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType {
   private EdmAnnotationHelper annotationHelper;
 
   public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn,
-          final List<? extends Schema> xmlSchemas, final ComplexType complexType) {
+      final ComplexType complexType) {
 
     FullQualifiedName baseTypeName = null;
-    if (complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType) {
-      final String baseType = ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).getBaseType();
-      baseTypeName = baseType == null
-              ? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName();
-    }
-    final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, xmlSchemas, complexType);
+    final String baseType = complexType.getBaseType();
+    baseTypeName = baseType == null
+        ? null : new EdmTypeInfo.Builder().setTypeExpression(baseType).build().getFullQualifiedName();
+    final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, fqn, baseTypeName, complexType);
     instance.baseType = instance.buildBaseType(baseTypeName);
 
     return instance;
   }
 
   private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
-          final List<? extends Schema> xmlSchemas, final ComplexType complexType) {
+      final ComplexType complexType) {
 
     super(edm, fqn, baseTypeName);
-    this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, complexType);
-    if (complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType) {
-      this.annotationHelper = new EdmAnnotationHelperImpl(edm,
-              (org.apache.olingo.client.api.edm.xml.ComplexType) complexType);
-    }
+    this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), complexType);
+    this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
index 04a4e4e..3d1a624 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java
@@ -25,7 +25,6 @@ import org.apache.olingo.client.api.edm.xml.ActionImport;
 import org.apache.olingo.client.api.edm.xml.EntityContainer;
 import org.apache.olingo.client.api.edm.xml.EntitySet;
 import org.apache.olingo.client.api.edm.xml.FunctionImport;
-import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.client.api.edm.xml.Singleton;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmActionImport;
@@ -46,35 +45,29 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
   private EdmAnnotationHelper helper;
 
   public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
-          final EntityContainer xmlEntityContainer, final List<? extends Schema> xmlSchemas) {
+      final EntityContainer xmlEntityContainer) {
 
     super(edm, entityContainerName, xmlEntityContainer.getExtends() == null
-            ? null : new FullQualifiedName(xmlEntityContainer.getExtends()));
+        ? null : new FullQualifiedName(xmlEntityContainer.getExtends()));
 
     this.xmlEntityContainer = xmlEntityContainer;
-    if (xmlEntityContainer instanceof EntityContainer) {
-      this.helper = new EdmAnnotationHelperImpl(edm,
-              (EntityContainer) xmlEntityContainer);
-    }
+    this.helper = new EdmAnnotationHelperImpl(edm, xmlEntityContainer);
   }
 
   @Override
   public boolean isDefault() {
-    return xmlEntityContainer instanceof EntityContainer
-            ? true
-            : xmlEntityContainer.isDefaultEntityContainer();
+    return true;
   }
 
   @Override
   protected EdmSingleton createSingleton(final String singletonName) {
-    final Singleton singleton = ((EntityContainer) xmlEntityContainer).
-            getSingleton(singletonName);
+    final Singleton singleton = xmlEntityContainer.getSingleton(singletonName);
     return singleton == null
-            ? null
-            : new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder().
-                    setTypeExpression(singleton.getEntityType()).
-                    setDefaultNamespace(entityContainerName.getNamespace()).
-                    build().getFullQualifiedName(), singleton);
+        ? null
+        : new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder().
+            setTypeExpression(singleton.getEntityType()).
+            setDefaultNamespace(entityContainerName.getNamespace()).
+            build().getFullQualifiedName(), singleton);
   }
 
   @Override
@@ -84,11 +77,8 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
     final EntitySet entitySet = xmlEntityContainer.getEntitySet(entitySetName);
     if (entitySet != null) {
       final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()).
-              setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
-      if (entitySet instanceof EntitySet) {
-        result = new EdmEntitySetImpl(edm, this, entitySetName, entityType,
-                (EntitySet) entitySet);
-      } 
+          setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
+      result = new EdmEntitySetImpl(edm, this, entitySetName, entityType, entitySet);
     }
 
     return result;
@@ -98,13 +88,10 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
   protected EdmActionImport createActionImport(final String actionImportName) {
     EdmActionImport result = null;
 
-    if (xmlEntityContainer instanceof EntityContainer) {
-      final ActionImport actionImport = ((EntityContainer) xmlEntityContainer).
-              getActionImport(actionImportName);
-      if (actionImport != null) {
-        result = new EdmActionImportImpl(edm, this, actionImportName, actionImport);
-      }
-    } 
+    final ActionImport actionImport = xmlEntityContainer.getActionImport(actionImportName);
+    if (actionImport != null) {
+      result = new EdmActionImportImpl(edm, this, actionImportName, actionImport);
+    }
     return result;
   }
 
@@ -114,10 +101,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
 
     final FunctionImport functionImport = xmlEntityContainer.getFunctionImport(functionImportName);
     if (functionImport != null) {
-      if (functionImport instanceof org.apache.olingo.client.api.edm.xml.FunctionImport) {
-        result = new EdmFunctionImportImpl(edm, this, functionImportName,
-                (org.apache.olingo.client.api.edm.xml.FunctionImport) functionImport);
-      } 
+      result = new EdmFunctionImportImpl(edm, this, functionImportName, functionImport);
     }
 
     return result;
@@ -130,15 +114,11 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
       for (EntitySet entitySet : localEntitySets) {
         EdmEntitySet edmSet;
         final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()).
-                setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
-        if (entitySet instanceof EntitySet) {
-          edmSet = new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType,
-                  (EntitySet) entitySet);
-          entitySets.put(edmSet.getName(), edmSet);
-        } 
+            setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName();
+        edmSet = new EdmEntitySetImpl(edm, this, entitySet.getName(), entityType, entitySet);
+        entitySets.put(edmSet.getName(), edmSet);
       }
     }
-
   }
 
   @Override
@@ -146,22 +126,18 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
     final List<? extends FunctionImport> localFunctionImports = xmlEntityContainer.getFunctionImports();
     for (FunctionImport functionImport : localFunctionImports) {
       EdmFunctionImport edmFunctionImport;
-      if (functionImport instanceof org.apache.olingo.client.api.edm.xml.FunctionImport) {
-        edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(),
-                (org.apache.olingo.client.api.edm.xml.FunctionImport) functionImport);
-        functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
-      } 
+      edmFunctionImport = new EdmFunctionImportImpl(edm, this, functionImport.getName(), functionImport);
+      functionImports.put(edmFunctionImport.getName(), edmFunctionImport);
     }
   }
 
   @Override
   protected void loadAllSingletons() {
-    final List<Singleton> localSingletons =
-            ((EntityContainer) xmlEntityContainer).getSingletons();
+    final List<Singleton> localSingletons = xmlEntityContainer.getSingletons();
     if (localSingletons != null) {
       for (Singleton singleton : localSingletons) {
         singletons.put(singleton.getName(), new EdmSingletonImpl(edm, this, singleton.getName(),
-                new EdmTypeInfo.Builder().
+            new EdmTypeInfo.Builder().
                 setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()).
                 build().getFullQualifiedName(), singleton));
       }
@@ -170,16 +146,13 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
 
   @Override
   protected void loadAllActionImports() {
-    if (xmlEntityContainer instanceof EntityContainer) {
-      final List<ActionImport> localActionImports =
-              ((EntityContainer) xmlEntityContainer).getActionImports();
-      if (actionImports != null) {
-        for (ActionImport actionImport : localActionImports) {
-          actionImports.put(actionImport.getName(),
-                  new EdmActionImportImpl(edm, this, actionImport.getName(), actionImport));
-        }
+    final List<ActionImport> localActionImports = xmlEntityContainer.getActionImports();
+    if (actionImports != null) {
+      for (ActionImport actionImport : localActionImports) {
+        actionImports.put(actionImport.getName(), new EdmActionImportImpl(edm, this, actionImport.getName(),
+            actionImport));
       }
-    } 
+    }
   }
 
   @Override
@@ -194,7 +167,7 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
 
   @Override
   public List<EdmAnnotation> getAnnotations() {
-    return helper == null ? Collections.<EdmAnnotation>emptyList() : helper.getAnnotations();
+    return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
index 2dabbbf..4fef9a2 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java
@@ -24,7 +24,6 @@ import java.util.Map;
 
 import org.apache.olingo.client.api.edm.xml.EntityType;
 import org.apache.olingo.client.api.edm.xml.PropertyRef;
-import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmAnnotation;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
@@ -44,20 +43,19 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
 
   private EdmAnnotationHelper annotationHelper;
 
-  public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn,
-      final List<? extends Schema> xmlSchemas, final EntityType entityType) {
+  public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final EntityType entityType) {
 
     final FullQualifiedName baseTypeName = entityType.getBaseType() == null
         ? null
         : new EdmTypeInfo.Builder().setTypeExpression(entityType.getBaseType()).build().getFullQualifiedName();
-    final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, fqn, baseTypeName, xmlSchemas, entityType);
+    final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, fqn, baseTypeName, entityType);
     instance.baseType = instance.buildBaseType(baseTypeName);
 
     if (instance.baseType == null) {
       instance.entityBaseType = null;
 
       final List<EdmKeyPropertyRef> edmKey;
-      //Abstract EntityTypes do not necessarily have keys
+      // Abstract EntityTypes do not necessarily have keys
       if (entityType.isAbstractType() && entityType.getKey() == null) {
         edmKey = new ArrayList<EdmKeyPropertyRef>();
       } else {
@@ -76,14 +74,11 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType {
   }
 
   private EdmEntityTypeImpl(final Edm edm, final FullQualifiedName fqn, final FullQualifiedName baseTypeName,
-      final List<? extends Schema> xmlSchemas, final EntityType entityType) {
+      final EntityType entityType) {
 
     super(edm, fqn, baseTypeName, entityType.isHasStream());
-    this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, entityType);
-    if (entityType instanceof EntityType) {
-      this.annotationHelper = new EdmAnnotationHelperImpl(edm,
-          (EntityType) entityType);
-    }
+    this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), entityType);
+    this.annotationHelper = new EdmAnnotationHelperImpl(edm, entityType);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
index 4e8fc8f..a82e252 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -44,9 +44,7 @@ public class EdmParameterImpl extends AbstractEdmParameter {
     super(edm, parameter.getName(), new FullQualifiedName(parameter.getType()));
     this.parameter = parameter;
     this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(parameter.getType()).build();
-    if (parameter instanceof Parameter) {
-      this.helper = new EdmAnnotationHelperImpl(edm, (Parameter) parameter);
-    }
+    this.helper = new EdmAnnotationHelperImpl(edm, parameter);
   }
 
   @Override
@@ -81,9 +79,8 @@ public class EdmParameterImpl extends AbstractEdmParameter {
 
   @Override
   public SRID getSrid() {
-    return (parameter instanceof Parameter)
-            ? ((Parameter) parameter).getSrid()
-            : null;
+    return parameter.getSrid();
+
   }
 
   @Override
@@ -93,7 +90,7 @@ public class EdmParameterImpl extends AbstractEdmParameter {
 
   @Override
   public List<EdmAnnotation> getAnnotations() {
-    return helper == null ? Collections.<EdmAnnotation>emptyList() : helper.getAnnotations();
+    return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f4636407/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
index 6b2e189..9c34472 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -48,9 +48,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty {
     this.structuredTypeName = structuredTypeName;
     this.property = property;
     this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType()).build();
-    if (property instanceof Property) {
-      this.helper = new EdmAnnotationHelperImpl(edm, (Property) property);
-    }
+    this.helper = new EdmAnnotationHelperImpl(edm, property);
   }
 
   @Override
@@ -100,9 +98,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty {
 
   @Override
   public SRID getSrid() {
-    return (property instanceof Property)
-            ? ((Property) property).getSrid()
-            : null;
+    return property.getSrid();
   }
 
   @Override
@@ -117,7 +113,7 @@ public class EdmPropertyImpl extends AbstractEdmProperty {
 
   @Override
   public List<EdmAnnotation> getAnnotations() {
-    return helper == null ? Collections.<EdmAnnotation>emptyList() : helper.getAnnotations();
+    return helper == null ? Collections.<EdmAnnotation> emptyList() : helper.getAnnotations();
   }
 
 }