mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-04 23:59:09 +00:00
[OLINGO-786] Make Annotations annotatable
This commit is contained in:
parent
2ffb813931
commit
1ac59b22a8
@ -18,12 +18,11 @@
|
||||
*/
|
||||
package org.apache.olingo.commons.api.edm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is used to apply a group of annotations to a single model element.
|
||||
*/
|
||||
public interface EdmAnnotations {
|
||||
public interface EdmAnnotations extends EdmAnnotatable{
|
||||
|
||||
/**
|
||||
* @return a model element in the entity model to which this annotations is targeted
|
||||
@ -41,15 +40,4 @@ public interface EdmAnnotations {
|
||||
* @return the path to the target
|
||||
*/
|
||||
String getTargetPath();
|
||||
|
||||
/**
|
||||
* @param term
|
||||
* @return the annotation for the given term or null if not present
|
||||
*/
|
||||
EdmAnnotation getAnnotation(EdmTerm term);
|
||||
|
||||
/**
|
||||
* @return a list of all annotations
|
||||
*/
|
||||
List<EdmAnnotation> getAnnotations();
|
||||
}
|
||||
|
@ -18,31 +18,24 @@
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
||||
import org.apache.olingo.commons.api.edm.EdmAnnotations;
|
||||
import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
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.CsdlAnnotation;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
||||
|
||||
public class EdmAnnotationsImpl implements EdmAnnotations {
|
||||
public class EdmAnnotationsImpl extends AbstractEdmAnnotatable implements EdmAnnotations {
|
||||
|
||||
private final Edm edm;
|
||||
private final CsdlAnnotations annotationGroup;
|
||||
private EdmAnnotationsTarget target;
|
||||
private List<EdmAnnotation> annotations;
|
||||
|
||||
public EdmAnnotationsImpl(final Edm edm, final CsdlAnnotations annotationGroup) {
|
||||
super(edm, annotationGroup);
|
||||
this.edm = edm;
|
||||
this.annotationGroup = annotationGroup;
|
||||
}
|
||||
@ -121,33 +114,8 @@ public class EdmAnnotationsImpl implements EdmAnnotations {
|
||||
return annotationGroup.getQualifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmAnnotation getAnnotation(final EdmTerm term) {
|
||||
EdmAnnotation result = null;
|
||||
for (EdmAnnotation annotation : getAnnotations()) {
|
||||
if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) {
|
||||
result = annotation;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EdmAnnotation> getAnnotations() {
|
||||
if (annotations == null) {
|
||||
List<EdmAnnotation> annotationsLocal = new ArrayList<EdmAnnotation>();
|
||||
for (CsdlAnnotation annotation : annotationGroup.getAnnotations()) {
|
||||
annotationsLocal.add(new EdmAnnotationImpl(edm, annotation));
|
||||
}
|
||||
|
||||
annotations = Collections.unmodifiableList(annotationsLocal);
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetPath() {
|
||||
return annotationGroup.getTarget();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user