001: /* ReflectionUtils.java
002: *
003: * DDSteps - Data Driven JUnit Test Steps
004: * Copyright (C) 2005 Jayway AB
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License version 2.1 as published by the Free Software Foundation.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, visit
017: * http://www.opensource.org/licenses/lgpl-license.php
018: */
019: package org.ddsteps.mock;
020:
021: import java.lang.reflect.Method;
022: import java.util.Set;
023:
024: /**
025: * Reflection Utils interface. Useful when you want to mock away reflections utils.
026: *
027: * @author adam
028: * @version $Id: ReflectionUtils.java,v 1.1 2005/12/03 12:51:40 adamskogman Exp $
029: */
030: public interface ReflectionUtils {
031:
032: /**
033: * Finds all implemented methods in the class and all superclasses.
034: *
035: * @param clazz The class to search.
036: * @return (@link Set) of (@link Method). Not null.
037: */
038: abstract Set findAllImplementedMethods(final Class clazz);
039:
040: /**
041: * Finds ALL methods (implemented or abstract, not unimplemented interface methods) in superclasses of the class.
042: *
043: * @param clazz The class whose superclasses are searched.
044: * @return (@link Set) of (@link Method). Not null.
045: */
046: abstract Set findAllMethodsInSuperclasses(final Class clazz);
047:
048: /**
049: * Find all methods in all interfaces this class implements (superclasses too).
050: *
051: * @param clazz The class whose interfaces to search.
052: * @return (@link Set) of (@link Method). Not null.
053: */
054: abstract Set findInterfaceMethods(final Class clazz);
055:
056: /**
057: * Find all unimplemented methods, i.e. abstarct w/o implementation or interface method w/o implementation.
058: *
059: * @param clazz The class to search.
060: * @return (@link Set) of (@link Method). Not null.
061: */
062: abstract Set findAllAbstractMethods(final Class clazz);
063:
064: /**
065: * Find all methods implemended in the specific class, not in any superclass of that class.
066: *
067: * @param clazz The class to search.
068: * @return (@link Set) of (@link Method). Not null.
069: */
070: abstract Set findLocalImplementedMethods(final Class clazz);
071:
072: /**
073: * Find ONE method based on the name. Returns the first method found.
074: *
075: * @param clazz
076: * @param methodName
077: * @return A Method if found.
078: * @throws NoSuchMethodException If method could not be not found.
079: */
080: abstract Method findMethodByName(Class clazz, String methodName)
081: throws NoSuchMethodException;
082:
083: /**
084: * Find all methods in a class. Includes abstract methods, but NOT unimplemented interface methods.
085: *
086: * @param clazz The class to search.
087: * @return (@link Set) of (@link Method). Not null.
088: */
089: abstract Set findAllMethods(final Class clazz);
090:
091: /**
092: * Tests if a method is final.
093: *
094: * @param method The method, not null.
095: * @return True if final
096: */
097: abstract boolean isFinal(Method method);
098:
099: /**
100: * Tests if a method is native.
101: *
102: * @param method The method, not null.
103: * @return True if native
104: */
105: abstract boolean isNative(Method method);
106:
107: /**
108: * Check if a method is an override of a reference method.
109: *
110: * @param possibleOverride
111: * @param reference
112: * @return True if it is an override.
113: */
114: abstract boolean isOverride(Method possibleOverride,
115: Method reference);
116:
117: }
|