EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.support]

COVERAGE SUMMARY FOR SOURCE FILE [ReflectionUtils.java]

nameclass, %method, %block, %line, %
ReflectionUtils.java100% (1/1)50%  (1/2)92%  (35/38)88%  (7/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReflectionUtils100% (1/1)50%  (1/2)92%  (35/38)88%  (7/8)
ReflectionUtils (): void 0%   (0/1)0%   (0/3)0%   (0/1)
findMethod (Class, Class): Set 100% (1/1)100% (35/35)100% (7/7)

1/*
2 * Copyright 2014 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.batch.support;
17 
18import org.springframework.core.annotation.AnnotationUtils;
19 
20import java.lang.annotation.Annotation;
21import java.lang.reflect.Method;
22import java.util.HashSet;
23import java.util.Set;
24 
25/**
26 * Provides reflection based utilities for Spring Batch that are not available
27 * via Spring Core
28 *
29 * @author Michael Minella
30 * @since 2.2.6
31 */
32public class ReflectionUtils {
33 
34        private ReflectionUtils() {}
35 
36        /**
37         * Returns a {@link java.util.Set} of {@link java.lang.reflect.Method} instances that
38         * are annotated with the annotation provided.
39         *
40         * @param clazz The class to search for a method with the given annotation type
41         * @param annotationType The type of annotation to look for
42         * @return a set of {@link java.lang.reflect.Method} instances if any are found, an empty set if not.
43         */
44        public static final Set<Method> findMethod(Class clazz, Class<? extends Annotation> annotationType) {
45 
46                Method [] declaredMethods = org.springframework.util.ReflectionUtils.getAllDeclaredMethods(clazz);
47                Set<Method> results = new HashSet<Method>();
48 
49                for (Method curMethod : declaredMethods) {
50                        Annotation annotation = AnnotationUtils.findAnnotation(curMethod, annotationType);
51 
52                        if(annotation != null) {
53                                results.add(curMethod);
54                        }
55                }
56 
57                return results;
58        }
59}

[all classes][org.springframework.batch.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov