org.jtiger.assertion
Class Reflection

java.lang.Object
  extended by org.jtiger.assertion.Reflection

public final class Reflection
extends Object

Provides the ability to make assertions on Java reflection types.

Version:
2.1
Build Number 0376
Build Time 2006-07-28 01:50.16.218 CET (GMT + 1)
Author:
Tony Morris

Method Summary
static Constructor<?> assertHasConstructor(Class<?> c, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class has a constructor with the given parameter types.
static Constructor<?> assertHasDeclaredConstructor(Class<?> c, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class has a declared constructor with the given parameter types.
static Field assertHasDeclaredField(Class<?> c, String name, Object... message)
          Asserts that the given class has a declared field with the given name.
static Method assertHasDeclaredMethod(Class<?> c, String name, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class has a declared method with the given name and parameter types.
static Field assertHasField(Class<?> c, String name, Object... message)
          Asserts that the given class has a field with the given name.
static Method assertHasMethod(Class<?> c, String name, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class has a method with the given name and parameter types.
static void assertNotHasConstructor(Class<?> c, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class does not have a constructor with the given parameter types.
static void assertNotHasDeclaredConstructor(Class<?> c, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class does not have a declared constructor with the given parameter types.
static void assertNotHasDeclaredField(Class<?> c, String name, Object... message)
          Asserts that the given class does not have a declared field with the given name.
static void assertNotHasDeclaredMethod(Class<?> c, String name, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class does not have a declared method with the given name and parameter types.
static void assertNotHasField(Class<?> c, String name, Object... message)
          Asserts that the given class does not have a field with the given name.
static void assertNotHasMethod(Class<?> c, String name, Class<?>[] parameterTypes, Object... message)
          Asserts that the given class does not have a method with the given name and parameter types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertHasConstructor

public static Constructor<?> assertHasConstructor(Class<?> c,
                                                  Class<?>[] parameterTypes,
                                                  Object... message)
                                           throws AssertionException
Asserts that the given class has a constructor with the given parameter types.

Parameters:
c - The class to assert has the given constructor.
parameterTypes - The parameter types of the constructor.
message - The assertion message.
Returns:
The constructor that the given class has.
Throws:
AssertionException - If the given class does not have a constructor with the given parameter types.
See Also:
Class.getConstructor(Class[])

assertNotHasConstructor

public static void assertNotHasConstructor(Class<?> c,
                                           Class<?>[] parameterTypes,
                                           Object... message)
                                    throws AssertionException
Asserts that the given class does not have a constructor with the given parameter types.

Parameters:
c - The class to assert does not have the given constructor.
parameterTypes - The parameter types of the constructor.
message - The assertion message.
Throws:
AssertionException - If the given class has a constructor with the given parameter types.
See Also:
Class.getConstructor(Class[])

assertHasDeclaredConstructor

public static Constructor<?> assertHasDeclaredConstructor(Class<?> c,
                                                          Class<?>[] parameterTypes,
                                                          Object... message)
                                                   throws AssertionException
Asserts that the given class has a declared constructor with the given parameter types.

Parameters:
c - The class to assert has the given declared constructor.
parameterTypes - The parameter types of the declared constructor.
message - The assertion message.
Returns:
The declared constructor that the given class has.
Throws:
AssertionException - If the given class does not have a declared constructor with the given parameter types.
See Also:
Class.getDeclaredConstructor(Class[])

assertNotHasDeclaredConstructor

public static void assertNotHasDeclaredConstructor(Class<?> c,
                                                   Class<?>[] parameterTypes,
                                                   Object... message)
                                            throws AssertionException
Asserts that the given class does not have a declared constructor with the given parameter types.

Parameters:
c - The class to assert does not have the given declared constructor.
parameterTypes - The parameter types of the declared constructor.
message - The assertion message.
Throws:
AssertionException - If the given class has a declared constructor with the given parameter types.
See Also:
Class.getDeclaredConstructor(Class[])

assertHasMethod

public static Method assertHasMethod(Class<?> c,
                                     String name,
                                     Class<?>[] parameterTypes,
                                     Object... message)
                              throws AssertionException
Asserts that the given class has a method with the given name and parameter types.

Parameters:
c - The class to assert has the given method.
name - The name of the method.
parameterTypes - The parameter types of the method.
message - The assertion message.
Returns:
The method that the given class has.
Throws:
AssertionException - If the given class does not have a method with the given name and parameter types.
See Also:
Class.getMethod(String, Class[])

assertNotHasMethod

public static void assertNotHasMethod(Class<?> c,
                                      String name,
                                      Class<?>[] parameterTypes,
                                      Object... message)
                               throws AssertionException
Asserts that the given class does not have a method with the given name and parameter types.

Parameters:
c - The class to assert does not have the given method.
name - The name of the method.
parameterTypes - The parameter types of the method.
message - The assertion message.
Throws:
AssertionException - If the given class has a method with the given name and parameter types.
See Also:
Class.getMethod(String, Class[])

assertHasDeclaredMethod

public static Method assertHasDeclaredMethod(Class<?> c,
                                             String name,
                                             Class<?>[] parameterTypes,
                                             Object... message)
                                      throws AssertionException
Asserts that the given class has a declared method with the given name and parameter types.

Parameters:
c - The class to assert has the given method.
name - The name of the method.
parameterTypes - The parameter types of the method.
message - The assertion message.
Returns:
The method that the given class has.
Throws:
AssertionException - If the given class does not have a declared method with the given name and parameter types.
See Also:
Class.getDeclaredMethod(String, Class[])

assertNotHasDeclaredMethod

public static void assertNotHasDeclaredMethod(Class<?> c,
                                              String name,
                                              Class<?>[] parameterTypes,
                                              Object... message)
                                       throws AssertionException
Asserts that the given class does not have a declared method with the given name and parameter types.

Parameters:
c - The class to assert does not have the given method.
name - The name of the method.
parameterTypes - The parameter types of the method.
message - The assertion message.
Throws:
AssertionException - If the given class has a declared method with the given name and parameter types.
See Also:
Class.getDeclaredMethod(String, Class[])

assertHasField

public static Field assertHasField(Class<?> c,
                                   String name,
                                   Object... message)
                            throws AssertionException
Asserts that the given class has a field with the given name.

Parameters:
c - The class to assert has the given field.
name - The name of the field.
message - The assertion message.
Returns:
The field that the given class has.
Throws:
AssertionException - If the given class does not have a field with the given name.
See Also:
Class.getField(String)

assertNotHasField

public static void assertNotHasField(Class<?> c,
                                     String name,
                                     Object... message)
                              throws AssertionException
Asserts that the given class does not have a field with the given name.

Parameters:
c - The class to assert does not have the given field.
name - The name of the field.
message - The assertion message.
Throws:
AssertionException - If the given class has a field with the given name.
See Also:
Class.getField(String)

assertHasDeclaredField

public static Field assertHasDeclaredField(Class<?> c,
                                           String name,
                                           Object... message)
                                    throws AssertionException
Asserts that the given class has a declared field with the given name.

Parameters:
c - The class to assert has the given field.
name - The name of the field.
message - The assertion message.
Returns:
The field that the given class has.
Throws:
AssertionException - If the given class does not have a declared field with the given name.
See Also:
Class.getDeclaredField(String)

assertNotHasDeclaredField

public static void assertNotHasDeclaredField(Class<?> c,
                                             String name,
                                             Object... message)
                                      throws AssertionException
Asserts that the given class does not have a declared field with the given name.

Parameters:
c - The class to assert does not have the given field.
name - The name of the field.
message - The assertion message.
Throws:
AssertionException - If the given class has a declared field with the given name.
See Also:
Class.getDeclaredField(String)