use of com.sun.tools.xjc.generator.bean.field.FieldRenderer in project jaxb-ri by eclipse-ee4j.
the class BeanGenerator method generateFieldDecl.
/**
* Determines the FieldRenderer used for the given FieldUse,
* then generates the field declaration and accessor methods.
*
* The <code>fields</code> map will be updated with the newly
* created FieldRenderer.
*/
private FieldOutline generateFieldDecl(ClassOutlineImpl cc, CPropertyInfo prop) {
FieldRenderer fr = prop.realization;
if (// none is specified. use the default factory
fr == null) {
fr = model.options.getFieldRendererFactory().getDefault();
}
FieldOutline field = fr.generate(cc, prop);
fields.put(prop, field);
return field;
}
use of com.sun.tools.xjc.generator.bean.field.FieldRenderer in project jaxb-ri by eclipse-ee4j.
the class BIProperty method wrapUp.
/**
* Common finalization of {@link CPropertyInfo} for the create***Property methods.
*/
private <T extends CPropertyInfo> T wrapUp(T prop, XSComponent source) {
prop.javadoc = concat(javadoc, getBuilder().getBindInfo(source).getDocumentation());
if (prop.javadoc == null)
prop.javadoc = "";
// decide the realization.
FieldRenderer r;
OptionalPropertyMode opm = getOptionalPropertyMode();
if (prop.isCollection()) {
CollectionTypeAttribute ct = getCollectionType();
r = ct.get(getBuilder().model);
} else {
FieldRendererFactory frf = getBuilder().fieldRendererFactory;
// according to the spec we should bahave as in jaxb1. So we ignore possiblity that property could be nullable
switch(opm) {
// the property type can be primitive type if we are to ignore absence
case PRIMITIVE:
r = frf.getRequiredUnboxed();
break;
case WRAPPER:
// force the wrapper type
r = prop.isOptionalPrimitive() ? frf.getSingle() : frf.getDefault();
break;
case ISSET:
r = prop.isOptionalPrimitive() ? frf.getSinglePrimitiveAccess() : frf.getDefault();
break;
default:
throw new Error();
}
}
if (opm == OptionalPropertyMode.ISSET) {
// only isSet is allowed on a collection. these 3 modes aren't really symmetric.
// if the property is a primitive type, we need an explicit unset because
// we can't overload the meaning of set(null).
// if it's a collection, we need to be able to unset it so that we can distinguish
// null list and empty list.
r = new IsSetFieldRenderer(r, prop.isOptionalPrimitive() || prop.isCollection(), true);
}
prop.realization = r;
JType bt = getBaseType();
if (bt != null)
prop.baseType = bt;
return prop;
}
Aggregations