DATACMNS-825 - Allow usage of composed annotations using @AliasFor.
We now resolve composed annotation values using @AliasFor within AnnotationBasedPersistentProperty and BasicPersistentEntity. Nevertheless it is up to the individual store implementation to make use of this. Original pull request: #156.
This commit is contained in:
committed by
Oliver Gierke
parent
ae96301ab0
commit
a40e247c25
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2014 the original author or authors.
|
||||
* Copyright 2011-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
import org.springframework.data.annotation.AccessType.Type;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -223,14 +223,15 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
|
||||
continue;
|
||||
}
|
||||
|
||||
A annotation = AnnotationUtils.findAnnotation(method, annotationType);
|
||||
A annotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
|
||||
|
||||
if (annotation != null) {
|
||||
return cacheAndReturn(annotationType, annotation);
|
||||
}
|
||||
}
|
||||
|
||||
return cacheAndReturn(annotationType, field == null ? null : AnnotationUtils.getAnnotation(field, annotationType));
|
||||
return cacheAndReturn(annotationType,
|
||||
field == null ? null : AnnotatedElementUtils.findMergedAnnotation(field, annotationType));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2015 by the original author(s).
|
||||
* Copyright 2011-2016 by the original author(s).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.AssociationHandler;
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Jon Brisbin
|
||||
* @author Patryk Wasik
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implements MutablePersistentEntity<T, P> {
|
||||
|
||||
@@ -284,7 +285,7 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
*/
|
||||
public Object getTypeAlias() {
|
||||
|
||||
TypeAlias alias = getType().getAnnotation(TypeAlias.class);
|
||||
TypeAlias alias = AnnotatedElementUtils.findMergedAnnotation(getType(), TypeAlias.class);
|
||||
return alias == null ? null : StringUtils.hasText(alias.value()) ? alias.value() : null;
|
||||
}
|
||||
|
||||
@@ -366,7 +367,7 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
return annotation;
|
||||
}
|
||||
|
||||
annotation = AnnotationUtils.findAnnotation(getType(), annotationType);
|
||||
annotation = AnnotatedElementUtils.findMergedAnnotation(getType(), annotationType);
|
||||
annotationCache.put(annotationType, annotation);
|
||||
|
||||
return annotation;
|
||||
|
||||
Reference in New Issue
Block a user