Annotation Interface GenAsPrimitiveType
Indicates that the annotated class can be reduced to a simple, primitive field for serialization.
These classes, unlike the other "
GenAs..." classes do not extend from an "_" class, as
they require no generation and aren't backed by introspection. A value(), representing
the primitive type, is required. Currently supported values are String,
boolean, double, int, long, and
wt.fc.EnumeratedType (GenAsEnumeratedTypes are, in fact, implemented as
primitive types).
Annotated classes must implement the following:
- A constructor with a single argument of the same type as the
value(). - A method named
<value> <value-in-lowercase>Value()returning the current value of the primitive type (e.g.int intValue()) unless the primitive type is aString, in which case thetoStringmethod is used.
A complete (toy) example follows:
@com.ptc.windchill.annotations.metadata.GenAsPrimitiveType(long.class)
public class Example {
private long value;
public Example(final long value) {
this.value = value;
}
public long longValue() {
return this.value;
}
}
The externalization of primitive types is handled by the (annotated) classes that aggregate them;
the constructor is called as part of its readExternal logic and the "value" method as
part of its writeExternal logic.
Supported API: true
-
Element Details
-
value
Class valueThe type each instance of this class reduces to during serialization. Supported types areString,boolean,double,int,long, andwt.fc.EnumeratedType.Note that while
wt.fc.EnumeratedTypeis a supported type, this is not the way to model an enumerated type -- useGenAsEnumeratedTypeinstead.
-