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 role
      value - new value, which will be assigned to the element's attribute defined by role defined by getRole()
    • 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

      <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
    • asMap

      <T,​ U> Map<String,​U> asMap(T element)
      Returns:
      a value for this role adapted as a modifiable Map