Package spoon.reflect.meta
Interface RoleHandler
public interface RoleHandler
Enables client code to get and set a field based on a role for a CtElement.
One obtains instances of
RoleHandler
using the methods of RoleHandlerHelper
.
There is one role handler per role of CtRole
, they are set by RoleHandlerHelper
.-
Method Details
-
getValue
<T, U> U getValue(T element)- Parameters:
element
- a element from which the value will be get for this role- Returns:
- a value of the element on the role defined by
getRole()
-
setValue
<T, U> void setValue(T element, U value)- Parameters:
element
- a element whose value will be set for this rolevalue
- new value, which will be assigned to the element's attribute defined by role defined bygetRole()
-
getRole
CtRole getRole()- Returns:
- the role handled by this handler
-
getTargetType
Class<?> getTargetType()- Returns:
- the type of the class, which this handler can be applied to (eg CtMethod)
-
getValueClass
Class<?> getValueClass()- Returns:
- the type of returned value defined by
getRole()
-
getContainerKind
ContainerKind getContainerKind()- Returns:
- the container kind, to know whether an element, a list, a map, etc is returned.
-
asCollection
- Returns:
- a value for this role adapted as a modifiable Collection
-
asSet
- Returns:
- a value for this role adapted as a modifiable Set
-
asList
- Returns:
- a value for this role adapted as a modifiable List
-
asMap
- Returns:
- a value for this role adapted as a modifiable Map
-