Package groovy.transform
Annotation Type ExternalizeMethods
-
@Documented @Retention(RUNTIME) @Target(TYPE) public @interface ExternalizeMethodsClass annotation used to assist in the creation ofExternalizableclasses. The@ExternalizeMethodsannotation instructs the compiler to execute an AST transformation which addswriteExternal()andreadExternal()methods to a class and addsExternalizableto 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 astransientare ignored. This annotation is typically used in conjunction with the@ExternalizeVerifierannotation but most usually not directly but rather via@AutoExternalizablewhich is a shortcut for both annotations.Example usage:
import groovy.transform.*
Which will create a class of the following form:@ExternalizeMethodsclass 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 java.lang.String[]excludesComma separated list of property names to exclude from externalizing.booleanincludeFieldsInclude fields as well as properties when externalizing.
-