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 ofRoleHandler
using the methods ofRoleHandlerHelper
. There is one role handler per role ofCtRole
, they are set byRoleHandlerHelper
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T,U>
Collection<U>asCollection(T element)
<T,U>
List<U>asList(T element)
<T,U>
Map<String,U>asMap(T element)
<T,U>
Set<U>asSet(T element)
ContainerKind
getContainerKind()
CtRole
getRole()
Class<?>
getTargetType()
<T,U>
UgetValue(T element)
Class<?>
getValueClass()
<T,U>
voidsetValue(T element, U value)
-
-
-
Method Detail
-
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)
-
getContainerKind
ContainerKind getContainerKind()
- Returns:
- the container kind, to know whether an element, a list, a map, etc is returned.
-
asCollection
<T,U> Collection<U> asCollection(T element)
- Returns:
- a value for this role adapted as a modifiable Collection
-
asSet
<T,U> Set<U> asSet(T element)
- Returns:
- a value for this role adapted as a modifiable Set
-
asList
<T,U> List<U> asList(T element)
- Returns:
- a value for this role adapted as a modifiable List
-
-