|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PlasticClass
The representation of a class while it is being instrumented and transformed. PlasticClass allows
for an imperative style of development: the PlasticClass is provided to other objects; they can query it
for relevant fields or methods, and invoke methods that modify the class in various ways. Ultimately, the
end result is a ClassInstantiator
used to create instances of the fully instrumented and transformed class.
AnnotationAccess
to provide access to annotations on the type itself.
This class is expressly not thread safe; only a single thread should be responsible for operating on a
PlasticClass.
TODO: what about annotation inheritance?
Method Summary | ||
---|---|---|
PlasticClass |
addToString(String toStringValue)
Conditionally adds an implementation of toString() to the class, but only if it is not already
present in the class, or in a (transformed) super-class. |
|
List<PlasticField> |
getAllFields()
Returns all non-introduced fields, in sorted order by name. |
|
String |
getClassName()
Returns the fully qualified class name of the class being transformed. |
|
|
getFieldsWithAnnotation(Class<T> annotationType)
Matches all fields (claimed or not) that have the given annotation. |
|
List<PlasticMethod> |
getMethods()
Returns all methods of the class, in sorted order. |
|
|
getMethodsWithAnnotation(Class<T> annotationType)
Matches methods with the given annotation. |
|
String |
getSuperClassName()
Returns the name of the super-class of the class being transformed. |
|
List<PlasticField> |
getUnclaimedFields()
Returns all unclaimed fields, in sorted order by name. |
|
PlasticField |
introduceField(Class fieldType,
String suggestedName)
Convenience method that uses a Java class rather than a type name. |
|
PlasticField |
introduceField(String typeName,
String suggestedName)
Introduces a new private field into the class. |
|
Set<PlasticMethod> |
introduceInterface(Class interfaceType)
Introduces each method defined by the interface into the class. |
|
PlasticMethod |
introduceMethod(Method method)
A convenience that creates a MethodDescription from the Method and introduces that. |
|
PlasticMethod |
introduceMethod(MethodDescription description)
Returns an existing method declared in this class, or introduces a new method into this class. |
|
PlasticMethod |
introduceMethod(MethodDescription description,
InstructionBuilderCallback callback)
Returns an existing method declared in this class, or introduces a new method into this class. |
|
PlasticMethod |
introducePrivateMethod(String typeName,
String suggestedName,
String[] argumentTypes,
String[] exceptionTypes)
Introduces a new private method into the class, ensuring that the method name is unique. |
|
boolean |
isInterfaceImplemented(Class interfaceType)
Returns true if this class, or a super-class, implements the indicated interface. |
|
boolean |
isMethodImplemented(MethodDescription description)
Returns true if this class has an implementation of the indicated method, or a super-class provides a non-abstract implementation. |
|
PlasticClass |
onConstruct(ConstructorCallback callback)
Adds the callback for execution when an instance of the class is instantiated. |
|
PlasticClass |
proxyInterface(Class interfaceType,
PlasticField field)
Introduces the interface, and then invokes PlasticMethod.delegateTo(PlasticField) on each method
defined by the interface. |
Methods inherited from interface org.apache.tapestry5.plastic.AnnotationAccess |
---|
getAnnotation, hasAnnotation |
Method Detail |
---|
String getClassName()
<T extends Annotation> List<PlasticField> getFieldsWithAnnotation(Class<T> annotationType)
List<PlasticField> getAllFields()
List<PlasticField> getUnclaimedFields()
PlasticField.claim(Object)
PlasticField introduceField(String typeName, String suggestedName)
typeName
- the Java class name for the field, or (possibly) a primitive type name or an arraysuggestedName
- the suggested name for the field, which may be modified to ensure that the field name
is unique
PlasticField introduceField(Class fieldType, String suggestedName)
PlasticMethod introducePrivateMethod(String typeName, String suggestedName, String[] argumentTypes, String[] exceptionTypes)
typeName
- return type of methodsuggestedName
- suggested name for the method; the actual method name may be modified to ensure uniquenessargumentTypes
- types of any arguments (may be null)exceptionTypes
- type of any checked exceptions (may be null)
<T extends Annotation> List<PlasticMethod> getMethodsWithAnnotation(Class<T> annotationType)
List<PlasticMethod> getMethods()
PlasticMethod introduceMethod(MethodDescription description)
description
- describes the method name, visibility, return value, etc.
IllegalArgumentException
- if the method is abstract or staticPlasticMethod introduceMethod(MethodDescription description, InstructionBuilderCallback callback)
description
- describes the method name, visibility, return value, etc.callback
- used to create the implementation of the method
IllegalArgumentException
- if the method is abstract or staticPlasticMethod introduceMethod(Method method)
MethodDescription
from the Method and introduces that. This is often
invoked when walking the methods of an interface and introducing each of those methods.
Introduced methods are always concrete, not abstract. The abstract flag on the method modifiers will always be
stripped off, which is handy when introducing methods from an interface.
method
- to introduce
Set<PlasticMethod> introduceInterface(Class interfaceType)
PlasticClass proxyInterface(Class interfaceType, PlasticField field)
PlasticMethod.delegateTo(PlasticField)
on each method
defined by the interface.
interfaceType
- defines the interface to proxyfield
- field containing an object to delegate to
PlasticClass addToString(String toStringValue)
toString()
to the class, but only if it is not already
present in the class, or in a (transformed) super-class.
toStringValue
- the fixed value to be returned from invoking toString()
boolean isMethodImplemented(MethodDescription description)
boolean isInterfaceImplemented(Class interfaceType)
interfaceType
-
String getSuperClassName()
PlasticClass onConstruct(ConstructorCallback callback)
callback
- to execute at instance construction time
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |