@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface ExternalizeMethods
Externalizable
classes.
The @ExternalizeMethods
annotation instructs the compiler to execute an
AST transformation which adds writeExternal()
and readExternal()
methods
to a class and adds Externalizable
to the interfaces which the class implements.
The writeExternal()
method writes each property (and optionally field) of the class
while the readExternal()
method will read each one back in the same order.
Properties or fields marked as transient
are ignored.
This annotation is typically used in conjunction with the @ExternalizeVerifier
annotation but
most usually not directly but rather via @AutoExternalizable
which is a shortcut for both annotations.
Example usage:
import groovy.transform.*
@ExternalizeMethods
class Person {
String first, last
List favItems
Date since
}
Which will create a class of the following form:
class Person implements Externalizable { ... public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(first) out.writeObject(last) out.writeObject(favItems) out.writeObject(since) } public void readExternal(ObjectInput oin) { first = (String) oin.readObject() last = (String) oin.readObject() favItems = (List) oin.readObject() since = (Date) oin.readObject() } ... }
Modifier and Type | Optional Element and Description |
---|---|
String[] |
excludes
Comma separated list of property names to exclude from externalizing.
|
boolean |
includeFields
Include fields as well as properties when externalizing.
|
public abstract String[] excludes