ReflectiveHelper

Contains useful functions for translating class and type names to Strings and provides helper functions to access common tasks for working with reflections.

Querying methods and fields is cached.

class Object
trait Matchable
class Any

Value members

Concrete methods

def addToFieldCache(c: Class[_]): Unit
def addToMethodCache(c: Class[_]): Unit
def findMethod(on: AnyRef, name: String, args: Seq[Any]): Option[Method]

Find a method of the wrapped object by its name and argument list given.

Find a method of the wrapped object by its name and argument list given.

Value Params
args

the args function/method of interest

name

the name of the function/method of interest

on

the instance to search on

Returns

Some(Method) if the wrapped object provides the function/method in question, None otherwise

def hasMember(on: AnyRef, name: String): Boolean

Checks if the wrapped object provides a member (field or function/method) with the given name.

Checks if the wrapped object provides a member (field or function/method) with the given name.

Value Params
name

the name of the member (field or function/method) of interest

on

the instance to search on

Returns

true if the wrapped object provides the given member, false otherwise

def is[T <: AnyRef : ClassTag](on: AnyRef): Boolean

Checks if the wrapped object is of type T.

Checks if the wrapped object is of type T.

Type Params
T

the type to check

Value Params
on

the instance to search on

Returns

true if the wrapped object is of type T, false otherwise

def isInstanceOf(mani: String, that: AnyRef): Boolean

Compares two class names.

Compares two class names.

Value Params
mani

the first class name derived from a class manifest (e.g., from classTag) as String

that

the second class name already as instance of Any

Returns

true iff both names are the same, false otherwise

def isInstanceOf(mani: String, that: String): Boolean

Compares two class names.

Compares two class names.

Value Params
mani

the first class name derived from a class manifest (e.g., from classTag) as String

that

the second class name already as String

Returns

true iff both names are the same, false otherwise

def isSameInterface(roleInterface: Array[Method], restrInterface: Array[Method]): Boolean

Compares two interfaces given as Array of its Methods.

Compares two interfaces given as Array of its Methods.

Value Params
restrInterface

Array of Methods from the second interface

roleInterface

Array of Methods from the first interface

Returns

true iff all methods from the restrInterface can be found in roleInterface, false otherwise

def propertyOf[T](on: AnyRef, name: String): T

Returns the runtime content of type T of the field with the given name of the wrapped object.

Returns the runtime content of type T of the field with the given name of the wrapped object.

Type Params
T

the type of the field

Value Params
name

the name of the field of interest

on

the instance to search on

Returns

the runtime content of type T of the field with the given name of the wrapped object

def resultOf[T](on: AnyRef, m: Method, args: Seq[Any]): T

Returns the runtime result of type T of the given function and arguments by executing this function of the wrapped object.

Returns the runtime result of type T of the given function and arguments by executing this function of the wrapped object.

Type Params
T

the return type of the function

Value Params
args

the arguments of the function of interest

m

the function of interest

on

the instance to search on

Returns

the runtime result of type T of the function with the given name by executing this function of the wrapped object

def resultOf[T](on: AnyRef, name: String): T

Returns the runtime result of type T of the function with the given name by executing this function of the wrapped object.

Returns the runtime result of type T of the function with the given name by executing this function of the wrapped object.

Type Params
T

the return type of the function

Value Params
name

the name of the function of interest

on

the instance to search on

Returns

the runtime result of type T of the function with the given name by executing this function of the wrapped object

def setPropertyOf(on: AnyRef, name: String, value: Any): Unit

Sets the field given as name to the provided value.

Sets the field given as name to the provided value.

Value Params
name

the name of the field of interest

on

the instance to search on

value

the value to set for this field

def simpleName(t: String): String

Translates a Class or Type name to a String, i.e. removing anything before the last occurrence of "$" or ".".

Translates a Class or Type name to a String, i.e. removing anything before the last occurrence of "$" or ".".

Value Params
t

the Class or Type name as String

Returns

anything after the last occurrence of "$" or "."