Delete AnnotationAttributeExtractor
Delete `AnnotationAttributeExtractor` which is package private and no longer used. Closes gh-22753
This commit is contained in:
parent
72027b1746
commit
8bc74ad18d
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* An {@code AnnotationAttributeExtractor} is responsible for
|
||||
* {@linkplain #getAttributeValue extracting} annotation attribute values
|
||||
* from an underlying {@linkplain #getSource source} such as an
|
||||
* {@code Annotation} or a {@code Map}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
* @param <S> the type of source supported by this extractor
|
||||
* @see SynthesizedAnnotationInvocationHandler
|
||||
*/
|
||||
interface AnnotationAttributeExtractor<S> {
|
||||
|
||||
/**
|
||||
* Get the type of annotation that this extractor extracts attribute
|
||||
* values for.
|
||||
*/
|
||||
Class<? extends Annotation> getAnnotationType();
|
||||
|
||||
/**
|
||||
* Get the element that is annotated with an annotation of the annotation
|
||||
* type supported by this extractor.
|
||||
* @return the annotated element, or {@code null} if unknown
|
||||
*/
|
||||
@Nullable
|
||||
Object getAnnotatedElement();
|
||||
|
||||
/**
|
||||
* Get the underlying source of annotation attributes.
|
||||
*/
|
||||
S getSource();
|
||||
|
||||
/**
|
||||
* Get the attribute value from the underlying {@linkplain #getSource source}
|
||||
* that corresponds to the supplied attribute method.
|
||||
* @param attributeMethod an attribute method from the annotation type
|
||||
* supported by this extractor
|
||||
* @return the value of the annotation attribute
|
||||
*/
|
||||
@Nullable
|
||||
Object getAttributeValue(Method attributeMethod);
|
||||
|
||||
}
|
||||
|
|
@ -41,7 +41,6 @@ import org.springframework.util.ReflectionUtils;
|
|||
* @since 5.2
|
||||
* @param <A> the annotation type
|
||||
* @see Annotation
|
||||
* @see AnnotationAttributeExtractor
|
||||
* @see AnnotationUtils#synthesizeAnnotation(Annotation, AnnotatedElement)
|
||||
*/
|
||||
final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> implements InvocationHandler {
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.GroovyImplicitAliasesContextConfigClass;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.ImplicitAliasesContextConfig;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.Location1ImplicitAliasesContextConfigClass;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.Location2ImplicitAliasesContextConfigClass;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.Location3ImplicitAliasesContextConfigClass;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.ValueImplicitAliasesContextConfigClass;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.XmlImplicitAliasesContextConfigClass;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Abstract base class for tests involving concrete implementations of
|
||||
* {@link AbstractAliasAwareAnnotationAttributeExtractor}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.2.1
|
||||
*/
|
||||
public abstract class AbstractAliasAwareAnnotationAttributeExtractorTestCase {
|
||||
|
||||
@Test
|
||||
public void getAttributeValueForImplicitAliases() throws Exception {
|
||||
assertGetAttributeValueForImplicitAliases(GroovyImplicitAliasesContextConfigClass.class, "groovyScript");
|
||||
assertGetAttributeValueForImplicitAliases(XmlImplicitAliasesContextConfigClass.class, "xmlFile");
|
||||
assertGetAttributeValueForImplicitAliases(ValueImplicitAliasesContextConfigClass.class, "value");
|
||||
assertGetAttributeValueForImplicitAliases(Location1ImplicitAliasesContextConfigClass.class, "location1");
|
||||
assertGetAttributeValueForImplicitAliases(Location2ImplicitAliasesContextConfigClass.class, "location2");
|
||||
assertGetAttributeValueForImplicitAliases(Location3ImplicitAliasesContextConfigClass.class, "location3");
|
||||
}
|
||||
|
||||
private void assertGetAttributeValueForImplicitAliases(Class<?> clazz, String expected) throws Exception {
|
||||
Method xmlFile = ImplicitAliasesContextConfig.class.getDeclaredMethod("xmlFile");
|
||||
Method groovyScript = ImplicitAliasesContextConfig.class.getDeclaredMethod("groovyScript");
|
||||
Method value = ImplicitAliasesContextConfig.class.getDeclaredMethod("value");
|
||||
|
||||
AnnotationAttributeExtractor<?> extractor = createExtractorFor(clazz, expected, ImplicitAliasesContextConfig.class);
|
||||
|
||||
assertThat(extractor.getAttributeValue(value), is(expected));
|
||||
assertThat(extractor.getAttributeValue(groovyScript), is(expected));
|
||||
assertThat(extractor.getAttributeValue(xmlFile), is(expected));
|
||||
}
|
||||
|
||||
protected abstract AnnotationAttributeExtractor<?> createExtractorFor(Class<?> clazz, String expected, Class<? extends Annotation> annotationType);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue