SSJ  3.3.1
Stochastic Simulation in Java
Static Public Member Functions | List of all members
Introspection Class Reference

Provides utility methods for introspection using Java Reflection API. More...

Static Public Member Functions

static Method [] getMethods (Class<?> c)
 Returns all the methods declared and inherited by a class. More...
 
static boolean sameSignature (Method m1, Method m2)
 Determines if two methods m1 and m2 share the same signature. More...
 
static Field [] getFields (Class<?> c)
 Returns all the fields declared and inherited by a class. More...
 
static Method getMethod (Class<?> c, String name, Class[] pt) throws NoSuchMethodException
 This is like java.lang.Class.getMethod, except that it can return non-public methods. More...
 
static Field getField (Class<?> c, String name) throws NoSuchFieldException
 This is like java.lang.Class.getField, except that it can return non-public fields. More...
 
static String getFieldName (Object val)
 Returns the field name corresponding to the value of an enumerated type val. More...
 
static< T > T valueOf (Class< T > cls, String name)
 Returns the field of class cls corresponding to the name name. More...
 
static< T > T valueOfIgnoreCase (Class< T > cls, String name)
 Similar to valueOf(Class<T>,String), with case insensitive field name look-up. More...
 

Detailed Description

Provides utility methods for introspection using Java Reflection API.

Member Function Documentation

◆ getField()

static Field getField ( Class<?>  c,
String  name 
) throws NoSuchFieldException
static

This is like java.lang.Class.getField, except that it can return non-public fields.

Note that since this method uses java.lang.Class.getDeclaredField, it can throw a SecurityException if a security manager is present.

Parameters
cthe class being processed.
namethe name of the method.
Exceptions
NoSuchFieldExceptionif the field cannot be found.

◆ getFieldName()

static String getFieldName ( Object  val)
static

Returns the field name corresponding to the value of an enumerated type val.

This method gets the class of val and scans its fields to find a public static and final field containing val. If such a field is found, its name is returned. Otherwise, null is returned.

Parameters
valthe value of the enumerated type.
Returns
the field name or null.

◆ getFields()

static Field [] getFields ( Class<?>  c)
static

Returns all the fields declared and inherited by a class.

This is similar to java.lang.Class.getFields except that it enumerates non-public fields as well as public ones. This method uses java.lang.Class.getDeclaredFields to get the declared fields of c. It also gets the declared fields of superclasses and implemented interfaces.

Note that since this method uses java.lang.Class.getDeclaredFields, it can throw a SecurityException if a security manager is present.

Parameters
cthe class being processed.
Returns
the array of fields.

◆ getMethod()

static Method getMethod ( Class<?>  c,
String  name,
Class []  pt 
) throws NoSuchMethodException
static

This is like java.lang.Class.getMethod, except that it can return non-public methods.

Parameters
cthe class being processed.
namethe name of the method.
ptthe parameter types.
Exceptions
NoSuchMethodExceptionif the method cannot be found.

◆ getMethods()

static Method [] getMethods ( Class<?>  c)
static

Returns all the methods declared and inherited by a class.

This is similar to java.lang.Class.getMethods except that it enumerates non-public methods as well as public ones. This method uses java.lang.Class.getDeclaredMethods to get the declared methods of c. It also gets the declared methods of superclasses. If a method is defined in a superclass and overriden in a subclass, only the overriden method will be in the returned array.

Note that since this method uses java.lang.Class.getDeclaredMethods, it can throw a SecurityException if a security manager is present.

Parameters
cthe class being processed.
Returns
the array of methods.

◆ sameSignature()

static boolean sameSignature ( Method  m1,
Method  m2 
)
static

Determines if two methods m1 and m2 share the same signature.

For the signature to be identical, methods must have the same number of parameters and the same parameter types.

Parameters
m1the first method.
m2the second method.
Returns
true if the signatures are the same, false otherwise.

◆ valueOf()

static <T> T valueOf ( Class< T >  cls,
String  name 
)
static

Returns the field of class cls corresponding to the name name.

This method looks for a public, static, and final field with name name and returns its value. If no appropriate field can be found, an IllegalArgumentException is thrown.

Parameters
clsthe class to look for a field in.
namethe name of field.
Returns
the object in the field.
Exceptions
IllegalArgumentExceptionif name does not correspond to a valid field name.

◆ valueOfIgnoreCase()

static <T> T valueOfIgnoreCase ( Class< T >  cls,
String  name 
)
static

Similar to valueOf(Class<T>,String), with case insensitive field name look-up.

If cls defines several fields with the same case insensitive name name, an IllegalArgumentException is thrown.

Parameters
clsthe class to look for a field in.
namethe name of field.
Returns
the object in the field.
Exceptions
IllegalArgumentExceptionif name does not correspond to a valid field name, or if the class defines several fields with the same name.

The documentation for this class was generated from the following file: