From 16b94eb47e3b9f0274fd9ec66e68b729b00d5a17 Mon Sep 17 00:00:00 2001 From: Michael Bolz Date: Fri, 27 Mar 2015 13:41:03 +0100 Subject: [PATCH] [OLINGO-575] Edm cleanup: Remove EdmAnnotationHelperImpl --- ...rImpl.java => AbstractEdmAnnotatable.java} | 34 +++++++++---------- ...mElementImpl.java => AbstractEdmBase.java} | 10 +++--- ...mpl.java => AbstractEdmBindingTarget.java} | 20 ++--------- ...dmNamedImpl.java => AbstractEdmNamed.java} | 9 +++-- ...ionImpl.java => AbstractEdmOperation.java} | 24 +++---------- ...l.java => AbstractEdmOperationImport.java} | 24 +++---------- ...pl.java => AbstractEdmStructuredType.java} | 14 ++++---- .../core/edm/provider/EdmActionImpl.java | 4 +-- .../edm/provider/EdmActionImportImpl.java | 2 +- .../core/edm/provider/EdmAnnotationImpl.java | 18 ++-------- .../core/edm/provider/EdmComplexTypeImpl.java | 19 +---------- .../edm/provider/EdmEntityContainerImpl.java | 21 ++---------- .../core/edm/provider/EdmEntitySetImpl.java | 2 +- .../core/edm/provider/EdmEntityTypeImpl.java | 16 +-------- .../core/edm/provider/EdmEnumTypeImpl.java | 6 ++-- .../core/edm/provider/EdmFunctionImpl.java | 4 +-- .../edm/provider/EdmFunctionImportImpl.java | 2 +- .../core/edm/provider/EdmMemberImpl.java | 21 ++---------- .../provider/EdmNavigationPropertyImpl.java | 19 ++--------- .../core/edm/provider/EdmParameterImpl.java | 21 ++---------- .../core/edm/provider/EdmPropertyImpl.java | 21 ++---------- .../EdmReferentialConstraintImpl.java | 19 ++--------- .../core/edm/provider/EdmSingletonImpl.java | 2 +- .../core/edm/provider/EdmTermImpl.java | 18 ++-------- .../edm/provider/EdmTypeDefinitionImpl.java | 22 ++---------- .../core/edm/provider/EdmTypeImpl.java | 8 +++-- .../core/edm/provider/EdmTypeInfo.java | 26 +++----------- ...mplTest.java => AbstractEdmNamedTest.java} | 27 ++++++++++++--- .../core/edm/provider/EdmTypeImplTest.java | 19 ++++++++++- 29 files changed, 130 insertions(+), 322 deletions(-) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmAnnotationHelperImpl.java => AbstractEdmAnnotatable.java} (70%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmElementImpl.java => AbstractEdmBase.java} (80%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmBindingTargetImpl.java => AbstractEdmBindingTarget.java} (86%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmNamedImpl.java => AbstractEdmNamed.java} (79%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmOperationImpl.java => AbstractEdmOperation.java} (86%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmOperationImportImpl.java => AbstractEdmOperationImport.java} (78%) rename lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/{EdmStructuredTypeImpl.java => AbstractEdmStructuredType.java} (94%) rename lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/{EdmNamedImplTest.java => AbstractEdmNamedTest.java} (58%) diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmAnnotatable.java similarity index 70% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmAnnotatable.java index e4b9d9bbf..d36c3a24f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationHelperImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmAnnotatable.java @@ -1,26 +1,23 @@ /* * 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. */ package org.apache.olingo.commons.core.edm.provider; -import java.util.ArrayList; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAnnotatable; import org.apache.olingo.commons.api.edm.EdmAnnotation; @@ -28,16 +25,16 @@ import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.provider.Annotatable; import org.apache.olingo.commons.api.edm.provider.Annotation; -public class EdmAnnotationHelperImpl implements EdmAnnotatable { +import java.util.ArrayList; +import java.util.List; - private final Edm edm; +public abstract class AbstractEdmAnnotatable extends AbstractEdmBase implements EdmAnnotatable { private final Annotatable annotatable; - private List annotations; - public EdmAnnotationHelperImpl(final Edm edm, final Annotatable annotatable) { - this.edm = edm; + public AbstractEdmAnnotatable(final Edm edm, final Annotatable annotatable) { + super(edm); this.annotatable = annotatable; } @@ -57,11 +54,12 @@ public class EdmAnnotationHelperImpl implements EdmAnnotatable { public List getAnnotations() { if (annotations == null) { annotations = new ArrayList(); - for (Annotation annotation : annotatable.getAnnotations()) { - annotations.add(new EdmAnnotationImpl(edm, annotation)); + if(annotatable != null) { + for (Annotation annotation : annotatable.getAnnotations()) { + annotations.add(new EdmAnnotationImpl(edm, annotation)); + } } } return annotations; } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBase.java similarity index 80% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBase.java index 686e45db9..e6d3c6aa0 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBase.java @@ -19,11 +19,13 @@ package org.apache.olingo.commons.core.edm.provider; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmElement; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; -public abstract class EdmElementImpl extends EdmNamedImpl implements EdmElement { +public abstract class AbstractEdmBase implements EdmAnnotatable { - public EdmElementImpl(final Edm edm, final String name) { - super(edm, name); + protected final Edm edm; + + public AbstractEdmBase(final Edm edm) { + this.edm = edm; } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBindingTarget.java similarity index 86% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBindingTarget.java index b4b035f13..61bba662b 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmBindingTarget.java @@ -23,31 +23,27 @@ import java.util.Iterator; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.Target; import org.apache.olingo.commons.api.edm.provider.BindingTarget; import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding; -public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBindingTarget { +public abstract class AbstractEdmBindingTarget extends AbstractEdmNamed implements EdmBindingTarget { private final BindingTarget target; - private final EdmAnnotationHelperImpl helper; private final EdmEntityContainer container; private List navigationPropertyBindings; - public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, final BindingTarget target) { - super(edm, target.getName()); + public AbstractEdmBindingTarget(final Edm edm, final EdmEntityContainer container, final BindingTarget target) { + super(edm, target.getName(), target); this.container = container; this.target = target; - this.helper = new EdmAnnotationHelperImpl(edm, target); } @Override @@ -128,14 +124,4 @@ public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBi return bindingTarget; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmNamed.java similarity index 79% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmNamed.java index 93e758333..8835bc5f4 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNamedImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmNamed.java @@ -20,15 +20,14 @@ package org.apache.olingo.commons.core.edm.provider; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmNamed; +import org.apache.olingo.commons.api.edm.provider.Annotatable; -public abstract class EdmNamedImpl implements EdmNamed { - - protected final Edm edm; +public abstract class AbstractEdmNamed extends AbstractEdmAnnotatable implements EdmNamed { private final String name; - public EdmNamedImpl(final Edm edm, final String name) { - this.edm = edm; + public AbstractEdmNamed(final Edm edm, final String name, final Annotatable annotatable) { + super(edm, annotatable); this.name = name; } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperation.java similarity index 86% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperation.java index 217c73261..788a9749f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperation.java @@ -24,30 +24,27 @@ import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.EdmParameter; import org.apache.olingo.commons.api.edm.EdmReturnType; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.provider.Operation; import org.apache.olingo.commons.api.edm.provider.Parameter; -public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperation { +public abstract class AbstractEdmOperation extends EdmTypeImpl implements EdmOperation { protected final Operation operation; - protected final EdmAnnotationHelperImpl helper; private final Map parameters = new LinkedHashMap(); private String entitySetPath; private boolean isBound; private EdmReturnType returnType; private List parameterNames; - protected static T getInstance(final T instance) { + protected static T getInstance(final T instance) { final List providerParameters = instance.operation.getParameters(); if (providerParameters != null) { final List _parameters = new ArrayList(providerParameters.size()); @@ -71,12 +68,11 @@ public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperati return instance; } - protected EdmOperationImpl(final Edm edm, final FullQualifiedName name, final Operation operation, - final EdmTypeKind kind) { + protected AbstractEdmOperation(final Edm edm, final FullQualifiedName name, final Operation operation, + final EdmTypeKind kind) { - super(edm, name, kind); + super(edm, name, kind, operation); this.operation = operation; - this.helper = new EdmAnnotationHelperImpl(edm, operation); } protected void setParameters(final List _parameters) { @@ -159,16 +155,6 @@ public abstract class EdmOperationImpl extends EdmTypeImpl implements EdmOperati return null; } - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - @Override public String getEntitySetPath(){ return operation.getEntitySetPath(); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImportImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperationImport.java similarity index 78% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImportImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperationImport.java index 3ace16730..82c346506 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmOperationImportImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmOperationImport.java @@ -18,31 +18,25 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmOperationImport; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.Target; import org.apache.olingo.commons.api.edm.provider.OperationImport; -public abstract class EdmOperationImportImpl extends EdmNamedImpl implements EdmOperationImport { +public abstract class AbstractEdmOperationImport extends AbstractEdmNamed implements EdmOperationImport { protected final EdmEntityContainer container; private final Target entitySet; private EdmEntitySet returnedEntitySet; - private final EdmAnnotationHelperImpl helper; - public EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container, - final OperationImport operationImport) { - super(edm, operationImport.getName()); + public AbstractEdmOperationImport(final Edm edm, final EdmEntityContainer container, + final OperationImport operationImport) { + super(edm, operationImport.getName(), operationImport); this.container = container; - this.helper = new EdmAnnotationHelperImpl(edm, operationImport); this.entitySet = new Target.Builder(operationImport.getEntitySet(), container).build(); } @@ -80,14 +74,4 @@ public abstract class EdmOperationImportImpl extends EdmNamedImpl implements Edm public String getAnnotationsTargetPath() { return getName(); } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmStructuredTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmStructuredType.java similarity index 94% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmStructuredTypeImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmStructuredType.java index 014184df8..1d773eaa8 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmStructuredTypeImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/AbstractEdmStructuredType.java @@ -36,7 +36,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public abstract class EdmStructuredTypeImpl extends EdmTypeImpl implements EdmStructuredType { +public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements EdmStructuredType { protected EdmStructuredType baseType; protected FullQualifiedName baseTypeName; @@ -47,13 +47,13 @@ public abstract class EdmStructuredTypeImpl extends EdmTypeImpl implements EdmSt private Map navigationProperties; private final StructuralType structuredType; - public EdmStructuredTypeImpl( - final Edm edm, - final FullQualifiedName typeName, - final EdmTypeKind kind, - final StructuralType structuredType) { + public AbstractEdmStructuredType( + final Edm edm, + final FullQualifiedName typeName, + final EdmTypeKind kind, + final StructuralType structuredType) { - super(edm, typeName, kind); + super(edm, typeName, kind, structuredType); this.baseTypeName = structuredType.getBaseTypeFQN(); this.structuredType = structuredType; } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java index 292f234fe..822ebc883 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java @@ -24,10 +24,10 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.provider.Action; -public class EdmActionImpl extends EdmOperationImpl implements EdmAction { +public class EdmActionImpl extends AbstractEdmOperation implements EdmAction { public static EdmActionImpl getInstance(final Edm edm, final FullQualifiedName name, final Action action) { - return EdmOperationImpl.getInstance(new EdmActionImpl(edm, name, action)); + return AbstractEdmOperation.getInstance(new EdmActionImpl(edm, name, action)); } private EdmActionImpl(final Edm edm, final FullQualifiedName name, final Action action) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java index 5d9c68a19..7d93e9aa9 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java @@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.edm.EdmActionImport; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.provider.ActionImport; -public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport { +public class EdmActionImportImpl extends AbstractEdmOperationImport implements EdmActionImport { private final ActionImport actionImport; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java index 60eb0b40b..07523e681 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationImpl.java @@ -60,18 +60,15 @@ import org.apache.olingo.commons.core.edm.annotation.EdmPropertyValueImpl; import org.apache.olingo.commons.core.edm.annotation.EdmRecordImpl; import org.apache.olingo.commons.core.edm.annotation.EdmUrlRefImpl; -public class EdmAnnotationImpl implements EdmAnnotation { +public class EdmAnnotationImpl extends AbstractEdmAnnotatable implements EdmAnnotation { - private final Edm edm; private final Annotation annotation; - private final EdmAnnotationHelperImpl helper; private EdmTerm term; private EdmAnnotationExpression expression; public EdmAnnotationImpl(final Edm edm, final Annotation annotation) { - this.edm = edm; + super(edm, annotation); this.annotation = annotation; - this.helper = new EdmAnnotationHelperImpl(edm, annotation); } @Override @@ -225,15 +222,4 @@ public class EdmAnnotationImpl implements EdmAnnotation { } return expression; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java index 16ba2379b..4949d247c 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java @@ -18,21 +18,15 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmStructuredType; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.provider.ComplexType; -public class EdmComplexTypeImpl extends EdmStructuredTypeImpl implements EdmComplexType { - - private EdmAnnotationHelperImpl annotationHelper; +public class EdmComplexTypeImpl extends AbstractEdmStructuredType implements EdmComplexType { public static EdmComplexTypeImpl getInstance( final Edm edm, final FullQualifiedName name, final ComplexType complexType) { @@ -41,19 +35,8 @@ public class EdmComplexTypeImpl extends EdmStructuredTypeImpl implements EdmComp private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) { super(edm, name, EdmTypeKind.COMPLEX, complexType); - this.annotationHelper = new EdmAnnotationHelperImpl(edm, complexType); } - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return annotationHelper == null ? null : annotationHelper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return annotationHelper == null ? null : annotationHelper.getAnnotations(); - } - @Override protected EdmStructuredType buildBaseType(final FullQualifiedName baseTypeName) { EdmComplexType baseType = null; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java index 5d3eef32b..bcca96ae7 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java @@ -19,7 +19,6 @@ package org.apache.olingo.commons.core.edm.provider; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,13 +26,11 @@ import java.util.Map; import org.apache.olingo.commons.api.ODataException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmSingleton; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.ActionImport; import org.apache.olingo.commons.api.edm.provider.EdmProvider; @@ -43,11 +40,10 @@ import org.apache.olingo.commons.api.edm.provider.EntitySet; import org.apache.olingo.commons.api.edm.provider.FunctionImport; import org.apache.olingo.commons.api.edm.provider.Singleton; -public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityContainer { +public class EdmEntityContainerImpl extends AbstractEdmNamed implements EdmEntityContainer { private final EdmProvider provider; private EntityContainer container; - private EdmAnnotationHelperImpl helper; protected final FullQualifiedName entityContainerName; private final FullQualifiedName parentContainerName; @@ -66,7 +62,7 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final EntityContainerInfo entityContainerInfo) { - super(edm, entityContainerInfo.getContainerName().getName()); + super(edm, entityContainerInfo.getContainerName().getName(), null); this.provider = provider; this.entityContainerName = entityContainerInfo.getContainerName(); this.parentContainerName = entityContainerInfo.getExtendsContainer(); @@ -74,12 +70,11 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN, final EntityContainer entityContainer) { - super(edm, containerFQN.getName()); + super(edm, containerFQN.getName(), entityContainer); this.provider = provider; container = entityContainer; this.entityContainerName = containerFQN; this.parentContainerName = entityContainer.getExtendsContainerFQN(); - this.helper = new EdmAnnotationHelperImpl(edm, entityContainer); } @Override @@ -326,14 +321,4 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon public TargetType getAnnotationsTargetType() { return TargetType.EntityContainer; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper == null ? null : helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper == null ? Collections. emptyList() : helper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java index d69f6fed7..867b82ce4 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java @@ -23,7 +23,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.provider.EntitySet; -public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet { +public class EdmEntitySetImpl extends AbstractEdmBindingTarget implements EdmEntitySet { private EntitySet entitySet; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java index 84445aa0f..cdb51f521 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java @@ -24,22 +24,19 @@ import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; import org.apache.olingo.commons.api.edm.EdmStructuredType; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.provider.EntityType; import org.apache.olingo.commons.api.edm.provider.PropertyRef; -public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntityType { +public class EdmEntityTypeImpl extends AbstractEdmStructuredType implements EdmEntityType { private EntityType entityType; private boolean baseTypeChecked = false; - private EdmAnnotationHelperImpl annotationHelper; private final boolean hasStream; protected EdmEntityType entityBaseType; private final List keyPredicateNames = new ArrayList(); @@ -56,7 +53,6 @@ public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntit super(edm, name, EdmTypeKind.ENTITY, entityType); this.entityType = entityType; hasStream = entityType.hasStream(); - this.annotationHelper = new EdmAnnotationHelperImpl(edm, entityType); } @Override @@ -151,14 +147,4 @@ public class EdmEntityTypeImpl extends EdmStructuredTypeImpl implements EdmEntit public TargetType getAnnotationsTargetType() { return TargetType.EntityType; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return annotationHelper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return annotationHelper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java index df09c3c87..af56e38a0 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEnumTypeImpl.java @@ -42,13 +42,13 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType { private static final Set VALID_UNDERLYING_TYPES = new HashSet(); - { + static { VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Byte); VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.SByte); VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int16); VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int32); VALID_UNDERLYING_TYPES.add(EdmPrimitiveTypeKind.Int64); - }; + } private final EdmPrimitiveType underlyingType; private final EnumType enumType; @@ -58,7 +58,7 @@ public class EdmEnumTypeImpl extends EdmTypeImpl implements EdmEnumType { private LinkedHashMap membersMap; public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final EnumType enumType) { - super(edm, enumName, EdmTypeKind.ENUM); + super(edm, enumName, EdmTypeKind.ENUM, enumType); if (enumType.getUnderlyingType() == null) { underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImpl.java index 4a29d83cb..0279a780b 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImpl.java @@ -26,12 +26,12 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.api.edm.provider.Function; -public class EdmFunctionImpl extends EdmOperationImpl implements EdmFunction { +public class EdmFunctionImpl extends AbstractEdmOperation implements EdmFunction { private final Function function; public static EdmFunctionImpl getInstance(final Edm edm, final FullQualifiedName name, final Function function) { - return EdmOperationImpl.getInstance(new EdmFunctionImpl(edm, name, function)); + return AbstractEdmOperation.getInstance(new EdmFunctionImpl(edm, name, function)); } private EdmFunctionImpl(final Edm edm, final FullQualifiedName name, final Function function) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImportImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImportImpl.java index ead3116d4..b2e2397aa 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImportImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmFunctionImportImpl.java @@ -27,7 +27,7 @@ import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.FunctionImport; -public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport { +public class EdmFunctionImportImpl extends AbstractEdmOperationImport implements EdmFunctionImport { private final FunctionImport functionImport; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java index a7d136673..b3a6f1e74 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmMemberImpl.java @@ -18,26 +18,20 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMember; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.EnumMember; -public class EdmMemberImpl extends EdmNamedImpl implements EdmMember { +public class EdmMemberImpl extends AbstractEdmNamed implements EdmMember { - private final EdmAnnotationHelperImpl helper; private final FullQualifiedName enumFQN; private final EnumMember member; public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final EnumMember member) { - super(edm, member.getName()); + super(edm, member.getName(), member); this.enumFQN = enumFQN; this.member = member; - this.helper = new EdmAnnotationHelperImpl(edm, member); } @Override @@ -59,15 +53,4 @@ public class EdmMemberImpl extends EdmNamedImpl implements EdmMember { public String getValue() { return member.getValue(); } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyImpl.java index e72a98ef2..db75e0c3a 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmNavigationPropertyImpl.java @@ -22,32 +22,29 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; import org.apache.olingo.commons.api.edm.EdmStructuredType; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.NavigationProperty; import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint; -public class EdmNavigationPropertyImpl extends EdmElementImpl implements EdmNavigationProperty { +public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmElement, EdmNavigationProperty { private final FullQualifiedName structuredTypeName; private final NavigationProperty navigationProperty; - private final EdmAnnotationHelperImpl helper; private List referentialConstraints; private EdmEntityType typeImpl; private EdmNavigationProperty partnerNavigationProperty; public EdmNavigationPropertyImpl( final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) { - super(edm, navigationProperty.getName()); + super(edm, navigationProperty.getName(), navigationProperty); this.structuredTypeName = structuredTypeName; this.navigationProperty = navigationProperty; - this.helper = new EdmAnnotationHelperImpl(edm, navigationProperty); } @Override @@ -139,14 +136,4 @@ public class EdmNavigationPropertyImpl extends EdmElementImpl implements EdmNavi public FullQualifiedName getAnnotationsTargetFQN() { return structuredTypeName; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmParameterImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmParameterImpl.java index 157a779ae..097318522 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmParameterImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmParameterImpl.java @@ -18,29 +18,24 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmMapping; import org.apache.olingo.commons.api.edm.EdmParameter; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.Parameter; -public class EdmParameterImpl extends EdmElementImpl implements EdmParameter { +public class EdmParameterImpl extends AbstractEdmNamed implements EdmParameter, EdmElement { private final Parameter parameter; - private final EdmAnnotationHelperImpl helper; private final EdmTypeInfo typeInfo; private EdmType typeImpl; public EdmParameterImpl(final Edm edm, final Parameter parameter) { - super(edm, parameter.getName()); + super(edm, parameter.getName(), parameter); this.parameter = parameter; - this.helper = new EdmAnnotationHelperImpl(edm, parameter); this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(parameter.getType()).build(); } @@ -79,16 +74,6 @@ public class EdmParameterImpl extends EdmElementImpl implements EdmParameter { return parameter.getSrid(); } - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - @Override public EdmType getType() { if (typeImpl == null) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImpl.java index 973640eb6..14c3faf45 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmPropertyImpl.java @@ -18,34 +18,29 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmMapping; import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.Property; -public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty { +public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, EdmElement { private final FullQualifiedName structuredTypeName; private final Property property; private final EdmTypeInfo typeInfo; - private EdmAnnotationHelperImpl helper; private EdmType propertyType; public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final Property property) { - super(edm, property.getName()); + super(edm, property.getName(), property); this.structuredTypeName = structuredTypeName; this.property = property; typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build(); - this.helper = new EdmAnnotationHelperImpl(edm, property); } @Override @@ -125,16 +120,6 @@ public class EdmPropertyImpl extends EdmElementImpl implements EdmProperty { return structuredTypeName; } - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - @Override public boolean isPrimitive() { return typeInfo.isPrimitiveType(); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmReferentialConstraintImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmReferentialConstraintImpl.java index 4a8d7d871..ac38d2045 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmReferentialConstraintImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmReferentialConstraintImpl.java @@ -18,22 +18,17 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.provider.ReferentialConstraint; -public class EdmReferentialConstraintImpl implements EdmReferentialConstraint { +public class EdmReferentialConstraintImpl extends AbstractEdmAnnotatable implements EdmReferentialConstraint { - private final EdmAnnotationHelperImpl helper; private final ReferentialConstraint constraint; public EdmReferentialConstraintImpl(final Edm edm, final ReferentialConstraint constraint) { + super(edm, constraint); this.constraint = constraint; - this.helper = new EdmAnnotationHelperImpl(edm, constraint); } @Override @@ -45,14 +40,4 @@ public class EdmReferentialConstraintImpl implements EdmReferentialConstraint { public String getReferencedPropertyName() { return constraint.getReferencedProperty(); } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSingletonImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSingletonImpl.java index ca953dcc8..764a6c60a 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSingletonImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSingletonImpl.java @@ -23,7 +23,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmSingleton; import org.apache.olingo.commons.api.edm.provider.Singleton; -public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSingleton { +public class EdmSingletonImpl extends AbstractEdmBindingTarget implements EdmSingleton { public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) { super(edm, container, singleton); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTermImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTermImpl.java index e1f7ce098..146ff7e0f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTermImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTermImpl.java @@ -23,7 +23,6 @@ import java.util.List; import org.apache.commons.lang3.ClassUtils; import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmType; @@ -34,24 +33,22 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EdmTermImpl extends EdmNamedImpl implements EdmTerm { +public class EdmTermImpl extends AbstractEdmNamed implements EdmTerm { private static final Logger LOG = LoggerFactory.getLogger(EdmTermImpl.class); private final Term term; private final FullQualifiedName fqn; private final EdmTypeInfo typeInfo; - private final EdmAnnotationHelperImpl helper; private EdmType termType; private EdmTerm baseTerm; private List> appliesTo; public EdmTermImpl(final Edm edm, final String namespace, final Term term) { - super(edm, term.getName()); + super(edm, term.getName(), term); this.term = term; this.fqn = new FullQualifiedName(namespace, term.getName()); this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(term.getType()).build(); - this.helper = new EdmAnnotationHelperImpl(edm, term); } @Override @@ -146,15 +143,4 @@ public class EdmTermImpl extends EdmNamedImpl implements EdmTerm { public String getAnnotationsTargetPath() { return null; } - - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeDefinitionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeDefinitionImpl.java index 6831f07e1..9c6155fb6 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeDefinitionImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeDefinitionImpl.java @@ -18,15 +18,11 @@ */ package org.apache.olingo.commons.core.edm.provider; -import java.util.List; - import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; @@ -34,20 +30,17 @@ import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.api.edm.provider.TypeDefinition; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefinition { +public class EdmTypeDefinitionImpl extends AbstractEdmNamed implements EdmTypeDefinition { private TypeDefinition typeDefinition; private FullQualifiedName typeDefinitionName; private EdmPrimitiveType edmPrimitiveTypeInstance; - private final EdmAnnotationHelperImpl helper; public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName, final TypeDefinition typeDefinition) { - super(edm, typeDefinitionName.getName()); + super(edm, typeDefinitionName.getName(), typeDefinition); this.typeDefinitionName = typeDefinitionName; this.typeDefinition = typeDefinition; - - this.helper = new EdmAnnotationHelperImpl(edm, typeDefinition); } @Override @@ -163,19 +156,8 @@ public class EdmTypeDefinitionImpl extends EdmNamedImpl implements EdmTypeDefini return getFullQualifiedName(); } - @Override - public EdmAnnotation getAnnotation(final EdmTerm term) { - return helper.getAnnotation(term); - } - - @Override - public List getAnnotations() { - return helper.getAnnotations(); - } - @Override public String getAnnotationsTargetPath() { return getName(); } - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImpl.java index 337d70038..ff3cd6515 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeImpl.java @@ -22,14 +22,16 @@ import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; +import org.apache.olingo.commons.api.edm.provider.Annotatable; -public class EdmTypeImpl extends EdmNamedImpl implements EdmType { +public class EdmTypeImpl extends AbstractEdmNamed implements EdmType { protected final FullQualifiedName typeName; protected final EdmTypeKind kind; - public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind) { - super(edm, typeName.getName()); + public EdmTypeImpl(final Edm edm, final FullQualifiedName typeName, final EdmTypeKind kind, + final Annotatable annotatable) { + super(edm, typeName.getName(), annotatable); this.typeName = typeName; this.kind = kind; } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeInfo.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeInfo.java index 768ec00b7..c11e8806e 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeInfo.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmTypeInfo.java @@ -35,9 +35,7 @@ public class EdmTypeInfo { public static class Builder { private String typeExpression; - private String defaultNamespace; - private Edm edm; public Builder setTypeExpression(final String typeExpression) { @@ -62,25 +60,15 @@ public class EdmTypeInfo { } } - private final Edm edm; - private final boolean collection; - private final FullQualifiedName fullQualifiedName; - private EdmPrimitiveTypeKind primitiveType; - private EdmTypeDefinition typeDefinition; - private EdmEnumType enumType; - private EdmComplexType complexType; - private EdmEntityType entityType; private EdmTypeInfo(final Edm edm, final String typeExpression) { - this.edm = edm; - String baseType; final int collStartIdx = typeExpression.indexOf("Collection("); final int collEndIdx = typeExpression.lastIndexOf(')'); @@ -105,7 +93,6 @@ public class EdmTypeInfo { if (lastDotIdx == -1) { namespace = EdmPrimitiveType.EDM_NAMESPACE; typeName = baseType; - baseType = new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, baseType).toString(); } else { namespace = baseType.substring(0, lastDotIdx); typeName = baseType.substring(lastDotIdx + 1); @@ -115,9 +102,6 @@ public class EdmTypeInfo { throw new IllegalArgumentException("Null or empty type name in " + typeExpression); } - final StringBuilder exp = new StringBuilder(); - exp.append(baseType); - fullQualifiedName = new FullQualifiedName(namespace, typeName); try { @@ -125,14 +109,14 @@ public class EdmTypeInfo { } catch (final IllegalArgumentException e) { primitiveType = null; } - if (primitiveType == null && this.edm != null) { - typeDefinition = this.edm.getTypeDefinition(fullQualifiedName); + if (primitiveType == null && edm != null) { + typeDefinition = edm.getTypeDefinition(fullQualifiedName); if (typeDefinition == null) { - enumType = this.edm.getEnumType(fullQualifiedName); + enumType = edm.getEnumType(fullQualifiedName); if (enumType == null) { - complexType = this.edm.getComplexType(fullQualifiedName); + complexType = edm.getComplexType(fullQualifiedName); if (complexType == null) { - entityType = this.edm.getEntityType(fullQualifiedName); + entityType = edm.getEntityType(fullQualifiedName); } } } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNamedImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmNamedTest.java similarity index 58% rename from lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNamedImplTest.java rename to lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmNamedTest.java index 60897c1ac..04f0556d1 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNamedImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/AbstractEdmNamedTest.java @@ -18,25 +18,42 @@ */ package org.apache.olingo.server.core.edm.provider; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; import org.apache.olingo.commons.api.edm.EdmNamed; -import org.apache.olingo.commons.core.edm.provider.EdmNamedImpl; +import org.apache.olingo.commons.api.edm.provider.Annotatable; +import org.apache.olingo.commons.api.edm.provider.Annotation; +import org.apache.olingo.commons.core.edm.provider.AbstractEdmNamed; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import java.util.Arrays; +import java.util.List; -public class EdmNamedImplTest { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class AbstractEdmNamedTest { @Test public void getNameTest() { EdmNamed obj = new EdmNamedImplTester("Name"); assertEquals("Name", obj.getName()); + EdmAnnotatable an = (EdmAnnotatable) obj; + assertNotNull(an.getAnnotations().get(0)); } - private class EdmNamedImplTester extends EdmNamedImpl { + private class EdmNamedImplTester extends AbstractEdmNamed { public EdmNamedImplTester(final String name) { - super(null, name); + super(null, name, new AnnoTester()); } } + private class AnnoTester implements Annotatable { + @Override + public List getAnnotations() { + Annotation annotation = new Annotation(); + annotation.setTerm("NS.SimpleTerm"); + return Arrays.asList(annotation); + } + } } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java index 38938fd5e..ddfd15dc0 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java @@ -18,13 +18,20 @@ */ package org.apache.olingo.server.core.edm.provider; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; +import org.apache.olingo.commons.api.edm.provider.Annotatable; +import org.apache.olingo.commons.api.edm.provider.Annotation; import org.apache.olingo.commons.core.edm.provider.EdmTypeImpl; import org.junit.Test; +import java.util.Arrays; +import java.util.List; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class EdmTypeImplTest { @@ -34,12 +41,22 @@ public class EdmTypeImplTest { assertEquals("name", type.getName()); assertEquals("namespace", type.getNamespace()); assertEquals(EdmTypeKind.UNDEFINED, type.getKind()); + EdmAnnotatable an = (EdmAnnotatable) type; + assertNotNull(an.getAnnotations().get(0)); } private class EdmTypeImplTester extends EdmTypeImpl { public EdmTypeImplTester(final FullQualifiedName name, final EdmTypeKind kind) { - super(null, name, kind); + super(null, name, kind, new AnnoTester()); } } + private class AnnoTester implements Annotatable { + @Override + public List getAnnotations() { + Annotation annotation = new Annotation(); + annotation.setTerm("NS.SimpleTerm"); + return Arrays.asList(annotation); + } + } }