Package org.apache.tapestry5.plastic
Interface PlasticClass
- 
- All Superinterfaces:
- AnnotationAccess
 - All Known Implementing Classes:
- PlasticClassImpl
 
 public interface PlasticClass extends AnnotationAccess 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 aClassInstantiatorused to create instances of the fully instrumented and transformed class. The terminology is that a class that is being transformed is "plastic", but the end result is a normal concrete class (albeit in a different class loader). ImplementsAnnotationAccessto 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 SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description PlasticClassaddToString(String toStringValue)Conditionally adds an implementation oftoString()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.StringgetClassName()Returns the fully qualified class name of the class being transformed.<T extends Annotation>
 List<PlasticField>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.<T extends Annotation>
 List<PlasticMethod>getMethodsWithAnnotation(Class<T> annotationType)Matches methods with the given annotation.StringgetSuperClassName()Returns the name of the super-class of the class being transformed.List<PlasticField>getUnclaimedFields()Returns all unclaimed fields, in sorted order by name.PlasticFieldintroduceField(Class fieldType, String suggestedName)Convenience method that uses a Java class rather than a type name.PlasticFieldintroduceField(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.PlasticMethodintroduceMethod(Method method)A convenience that creates aMethodDescriptionfrom the Method and introduces that.PlasticMethodintroduceMethod(MethodDescription description)Returns an existing method declared in this class, or introduces a new method into this class.PlasticMethodintroduceMethod(MethodDescription description, InstructionBuilderCallback callback)Returns an existing method declared in this class, or introduces a new method into this class.PlasticMethodintroducePrivateMethod(String typeName, String suggestedName, String[] argumentTypes, String[] exceptionTypes)Introduces a new private method into the class, ensuring that the method name is unique.booleanisInterfaceImplemented(Class interfaceType)Returns true if this class, or a super-class, implements the indicated interface.booleanisMethodImplemented(MethodDescription description)Returns true if this class has an implementation of the indicated method, or a super-class provides a non-abstract implementation.PlasticClassonConstruct(ConstructorCallback callback)Adds the callback for execution when an instance of the class is instantiated.PlasticClassproxyInterface(Class interfaceType, PlasticField field)Introduces the interface, and then invokesPlasticMethod.delegateTo(PlasticField)on each method defined by the interface.PlasticClassproxyInterface(Class interfaceType, PlasticMethod method)Introduces the interface, and then invokesPlasticMethod.delegateTo(PlasticMethod)on each method defined by the interface.- 
Methods inherited from interface org.apache.tapestry5.plastic.AnnotationAccessgetAnnotation, hasAnnotation
 
- 
 
- 
- 
- 
Method Detail- 
getClassNameString getClassName() Returns the fully qualified class name of the class being transformed.
 - 
getFieldsWithAnnotation<T extends Annotation> List<PlasticField> getFieldsWithAnnotation(Class<T> annotationType) Matches all fields (claimed or not) that have the given annotation. Returns the fields in sorted order.- Returns:
- Unmodifiable List of fields.
 
 - 
getAllFieldsList<PlasticField> getAllFields() Returns all non-introduced fields, in sorted order by name.- Returns:
- Unmodifiable list of fields.
 
 - 
getUnclaimedFieldsList<PlasticField> getUnclaimedFields() Returns all unclaimed fields, in sorted order by name. This does not include introduced fields.- Returns:
- Unmodifiable list of fields.
- See Also:
- PlasticField.claim(Object)
 
 - 
introduceFieldPlasticField introduceField(String typeName, String suggestedName) Introduces a new private field into the class.- Parameters:
- typeName- the Java class name for the field, or (possibly) a primitive type name or an array
- suggestedName- the suggested name for the field, which may be modified to ensure that the field name is unique
- Returns:
- PlasticField for the introduced field
 
 - 
introduceFieldPlasticField introduceField(Class fieldType, String suggestedName) Convenience method that uses a Java class rather than a type name.
 - 
introducePrivateMethodPlasticMethod introducePrivateMethod(String typeName, String suggestedName, String[] argumentTypes, String[] exceptionTypes) Introduces a new private method into the class, ensuring that the method name is unique.- Parameters:
- typeName- return type of method
- suggestedName- suggested name for the method; the actual method name may be modified to ensure uniqueness
- argumentTypes- types of any arguments (may be null)
- exceptionTypes- type of any checked exceptions (may be null)
- Returns:
- new method, with default implementation
 
 - 
getMethodsWithAnnotation<T extends Annotation> List<PlasticMethod> getMethodsWithAnnotation(Class<T> annotationType) Matches methods with the given annotation.- Returns:
- Unmodifiable list of methods, in sorted order.
 
 - 
getMethodsList<PlasticMethod> getMethods() Returns all methods of the class, in sorted order. This does not include static methods, or any introduced methods.- Returns:
- Unmodifiable list of methods.
 
 - 
introduceMethodPlasticMethod introduceMethod(MethodDescription description) Returns an existing method declared in this class, or introduces a new method into this class. The method is created with default behavior. If the method overrides a non-private, non-abstract method implemented in a transformed super class, the the default behavior is to invoke that method and return its value. Otherwise, the default behavior is to ignore parameters and return 0, false, or null. Void methods will invoke the super-class implementation (if it exists) and return no value. It is allowed for the method description to indicate an abstract method; however the abstract flag will be removed, and a non-abstract method will be created.- Parameters:
- description- describes the method name, visibility, return value, etc.
- Returns:
- a new (or previously created) PlasticMethod for the method
- Throws:
- IllegalArgumentException- if the method is abstract or static
 
 - 
introduceMethodPlasticMethod introduceMethod(MethodDescription description, InstructionBuilderCallback callback) Returns an existing method declared in this class, or introduces a new method into this class. The method is created with default behavior. It is allowed for the method description to indicate an abstract method; however the abstract flag will be removed, and a non-abstract method will be created.- Parameters:
- description- describes the method name, visibility, return value, etc.
- callback- used to create the implementation of the method
- Returns:
- a new (or previously created) PlasticMethod for the method
- Throws:
- IllegalArgumentException- if the method is abstract or static
 
 - 
introduceMethodPlasticMethod introduceMethod(Method method) A convenience that creates aMethodDescriptionfrom 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.- Parameters:
- method- to introduce
- Returns:
- new (or previously created) PlasticMethod
 
 - 
introduceInterfaceSet<PlasticMethod> introduceInterface(Class interfaceType) Introduces each method defined by the interface into the class. Determines which new methods must be introduced in order to ensure that all methods of the interface are implemented. The newly introduced methods, if any, are returned.
 - 
proxyInterfacePlasticClass proxyInterface(Class interfaceType, PlasticField field) Introduces the interface, and then invokesPlasticMethod.delegateTo(PlasticField)on each method defined by the interface.- Parameters:
- interfaceType- defines the interface to proxy
- field- field containing an object to delegate to
- Returns:
- this plastic class, for further configuration
 
 - 
proxyInterfacePlasticClass proxyInterface(Class interfaceType, PlasticMethod method) Introduces the interface, and then invokesPlasticMethod.delegateTo(PlasticMethod)on each method defined by the interface.- Parameters:
- interfaceType- defines the interface to proxy
- method- method to delegate to
- Returns:
- this plastic class, for further configuration
- Since:
- 5.4.4
 
 - 
addToStringPlasticClass addToString(String toStringValue) Conditionally adds an implementation oftoString()to the class, but only if it is not already present in the class, or in a (transformed) super-class.- Parameters:
- toStringValue- the fixed value to be returned from invoking toString()
- Returns:
- this plastic class, for further configuration
 
 - 
isMethodImplementedboolean isMethodImplemented(MethodDescription description) Returns true if this class has an implementation of the indicated method, or a super-class provides a non-abstract implementation.
 - 
isInterfaceImplementedboolean isInterfaceImplemented(Class interfaceType) Returns true if this class, or a super-class, implements the indicated interface.- Parameters:
- interfaceType-
- Returns:
- true if the interface is implemented
 
 - 
getSuperClassNameString getSuperClassName() Returns the name of the super-class of the class being transformed.
 - 
onConstructPlasticClass onConstruct(ConstructorCallback callback) Adds the callback for execution when an instance of the class is instantiated.- Parameters:
- callback- to execute at instance construction time
 
 
- 
 
-