Package groovy.transform
Annotation Type ExternalizeMethods
-
@Documented @Retention(RUNTIME) @Target(TYPE) public @interface ExternalizeMethods
Class annotation used to assist in the creation ofExternalizable
classes. The@ExternalizeMethods
annotation instructs the compiler to execute an AST transformation which addswriteExternal()
andreadExternal()
methods to a class and addsExternalizable
to the interfaces which the class implements. ThewriteExternal()
method writes each property (and optionally field) of the class while thereadExternal()
method will read each one back in the same order. Properties or fields marked astransient
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.*
Which will create a class of the following form:@ExternalizeMethods
class Person { String first, last List favItems Date since }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() } ... }
- Since:
- 1.8.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description String[]
excludes
Comma separated list of property names to exclude from externalizing.boolean
includeFields
Include fields as well as properties when externalizing.
-
-
-
Element Detail
-
excludes
String[] excludes
Comma separated list of property names to exclude from externalizing. For convenience, a String with comma separated names can be used in addition to an array (using Groovy's literal list notation) of String values.- Default:
- {}
-
-