com.lexicalscope.fluentreflection
Interface FluentAccess<T>

Type Parameters:
T - the underlying type being reflected on
All Superinterfaces:
FluentAnnotated
All Known Subinterfaces:
FluentClass<T>, FluentObject<T>

public interface FluentAccess<T>
extends FluentAnnotated

Reflection access to a class or an object.

Author:
tim

Method Summary
 boolean assignableFromObject(Object value)
          True if the given object can be assigned to a variable of the type represented by this class
 boolean assignableTo(Class<?> klass)
          Is the parameter assignable from this class?
 FluentClass<T> boxedType()
          If this class is a primitive type return the wrapped type
 FluentObject<?> call(org.hamcrest.Matcher<? super FluentMethod> methodMatcher, Object... args)
          Call a method using a matcher, if one can be found that can also be called with the given arguments
 FluentObject<?> call(String name, Object... args)
          Call a method by name if one can be found that can be called with the given arguments
 boolean canBeBoxed(Class<?> from)
          Determines if this Class object is a primitive wrapper type, and the unwrapped type can be assigned from the parameter.
 boolean canBeUnboxed(Class<?> from)
          Determines if this Class object is a primitive type, and the wrapped type can be assigned from the parameter.
 Class<T> classUnderReflection()
          Obtain the class being reflected
 List<FluentField> declaredFields()
          All fields declared by this type
 List<FluentMethod> declaredMethods()
          All methods declared by this type
 FluentField field(ReflectionMatcher<FluentMember> fieldMatcher)
          Find field matching the supplied matcher
 List<FluentField> fields()
          All fields
 List<FluentField> fields(ReflectionMatcher<? super FluentField> fieldMatcher)
          Find all fields matching the supplied matcher
 List<FluentClass<?>> interfaces()
          All interfaces implemented by this type
 boolean isPrimitive()
          Determines if this Class object represents a primitive type.
 boolean isType(ReflectionMatcher<FluentClass<?>> typeMatcher)
          Does this type or any of its implemented types match the given matcher?
 boolean isUnboxable()
          Determines if this Class object represents the wrapper of a primitive type.
 FluentMethod method(org.hamcrest.Matcher<? super FluentMethod> methodMatcher)
          Find the first method matching the supplied matcher
 FluentMethod method(String name)
          Find the first method with the given name
 List<FluentMethod> methods()
          All methods
 List<FluentMethod> methods(org.hamcrest.Matcher<? super FluentMethod> methodMatcher)
          Find all methods matching the supplied matcher
 String name()
           
 String simpleName()
           
 List<FluentClass<?>> superclasses()
          Return the list of all superclasses with the immediate parent first
 Type type()
           
 FluentClass<?> typeArgument(int typeParameter)
           
 FluentClass<T> unboxedType()
          If this class is a primitive wrapper type return the unwrapped type
 
Methods inherited from interface com.lexicalscope.fluentreflection.FluentAnnotated
annotatedWith, annotatedWith, annotation, annotation
 

Method Detail

classUnderReflection

Class<T> classUnderReflection()
Obtain the class being reflected

Returns:
the class being reflected

interfaces

List<FluentClass<?>> interfaces()
All interfaces implemented by this type

Returns:
all the interfaces

superclasses

List<FluentClass<?>> superclasses()
Return the list of all superclasses with the immediate parent first

Returns:
list of superclasses nearest first

isType

boolean isType(ReflectionMatcher<FluentClass<?>> typeMatcher)
Does this type or any of its implemented types match the given matcher?

Parameters:
typeMatcher - matcher on the required type
Returns:
does the type or any of its supertypes match the given matcher

methods

List<FluentMethod> methods()
All methods

Returns:
all the methods

declaredMethods

List<FluentMethod> declaredMethods()
All methods declared by this type

Returns:
methods declared by this type

methods

List<FluentMethod> methods(org.hamcrest.Matcher<? super FluentMethod> methodMatcher)
Find all methods matching the supplied matcher

Parameters:
methodMatcher - matches the methods
Returns:
The methods matching the supplied matcher

method

FluentMethod method(org.hamcrest.Matcher<? super FluentMethod> methodMatcher)
Find the first method matching the supplied matcher

Parameters:
methodMatcher - matches the method
Returns:
The method matching the supplied matcher

method

FluentMethod method(String name)
Find the first method with the given name

Parameters:
name - the name of the method
Returns:
The method matching the name

call

FluentObject<?> call(String name,
                     Object... args)
Call a method by name if one can be found that can be called with the given arguments

Parameters:
name - the name of the method
args - the arguments of the method
Returns:
the result of calling the method

call

FluentObject<?> call(org.hamcrest.Matcher<? super FluentMethod> methodMatcher,
                     Object... args)
Call a method using a matcher, if one can be found that can also be called with the given arguments

Parameters:
methodMatcher - matches the method
args - the arguments of the method
Returns:
the result of calling the method

fields

List<FluentField> fields()
All fields

Returns:
all the fields

fields

List<FluentField> fields(ReflectionMatcher<? super FluentField> fieldMatcher)
Find all fields matching the supplied matcher

Parameters:
fieldMatcher - matches the field
Returns:
The fields matching the supplied matcher

declaredFields

List<FluentField> declaredFields()
All fields declared by this type

Returns:
fields declared by this type

field

FluentField field(ReflectionMatcher<FluentMember> fieldMatcher)
Find field matching the supplied matcher

Parameters:
fieldMatcher - matches the field
Returns:
The first field matching the supplied matcher

isPrimitive

boolean isPrimitive()
Determines if this Class object represents a primitive type.

Returns:
true if and only if this class represents a primitive type

isUnboxable

boolean isUnboxable()
Determines if this Class object represents the wrapper of a primitive type.

Returns:
true iff this class is one of the primative wrapper types

canBeBoxed

boolean canBeBoxed(Class<?> from)
Determines if this Class object is a primitive wrapper type, and the unwrapped type can be assigned from the parameter. Can the parameter be boxed into this type?

Parameters:
from - the type that maybe be assignable to this type
Returns:
true iff this class is a primitive wrapper type, and the unwrapped type can be assigned from the parameter

canBeUnboxed

boolean canBeUnboxed(Class<?> from)
Determines if this Class object is a primitive type, and the wrapped type can be assigned from the parameter. Can the parameter be unboxed into this type?

Parameters:
from - the type that maybe be assignable to this type
Returns:
true iff this class is a primitive type, and the wrapped type can be assigned from the parameter

boxedType

FluentClass<T> boxedType()
If this class is a primitive type return the wrapped type

Returns:
the wrapped type or this

unboxedType

FluentClass<T> unboxedType()
If this class is a primitive wrapper type return the unwrapped type

Returns:
the unwrapped type or this

assignableFromObject

boolean assignableFromObject(Object value)
True if the given object can be assigned to a variable of the type represented by this class

Parameters:
value - the value that might be assigned
Returns:
true iff the value can be assigned to variables of this type

assignableTo

boolean assignableTo(Class<?> klass)
Is the parameter assignable from this class?

Parameters:
klass - the class that may be assignable to
Returns:
true iff the parameter is assignable from this class

typeArgument

FluentClass<?> typeArgument(int typeParameter)

name

String name()
Returns:
the name of the class under reflection

simpleName

String simpleName()
Returns:
the simple name of the class under reflection

type

Type type()
Returns:
the underlying type instance


Copyright © 2011-2012 lexicalscope. All Rights Reserved.