Example usage for org.springframework.data.util AnnotationDetectionMethodCallback hasFoundAnnotation

List of usage examples for org.springframework.data.util AnnotationDetectionMethodCallback hasFoundAnnotation

Introduction

In this page you can find the example usage for org.springframework.data.util AnnotationDetectionMethodCallback hasFoundAnnotation.

Prototype

public boolean hasFoundAnnotation() 

Source Link

Document

Returns whether an annotation was found.

Usage

From source file:org.springframework.data.rest.core.projection.ProxyProjectionFactory.java

/**
 * Inspects the given target type for methods with {@link Value} annotations and caches the result. Will create a
 * {@link SpelEvaluatingMethodInterceptor} if an annotation was found or return the delegate as is if not.
 * /*w  w  w  .  j a  va 2 s . co  m*/
 * @param source The backing source object.
 * @param projectionType the proxy target type.
 * @param delegate the root {@link MethodInterceptor}.
 * @return
 */
private MethodInterceptor getSpelMethodInterceptorIfNecessary(Object source, Class<?> projectionType,
        MethodInterceptor delegate) {

    if (!typeCache.containsKey(projectionType)) {

        AnnotationDetectionMethodCallback<Value> callback = new AnnotationDetectionMethodCallback<Value>(
                Value.class);
        ReflectionUtils.doWithMethods(projectionType, callback);

        typeCache.put(projectionType, callback.hasFoundAnnotation());
    }

    return typeCache.get(projectionType) ? new SpelEvaluatingMethodInterceptor(delegate, source, beanFactory)
            : delegate;
}