use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIXSubstitutable in project jaxb-ri by eclipse-ee4j.
the class DefaultClassBinder method isCollapsable.
/**
* Returns true if the complex type of the given element can be "optimized away"
* and unified with its parent element decl to form a single class.
*/
private boolean isCollapsable(XSElementDecl decl) {
XSType type = decl.getType();
if (!type.isComplexType())
// not a complex type
return false;
if (decl.getSubstitutables().size() > 1 || decl.getSubstAffiliation() != null)
// because element substitution calls for a proper JAXBElement hierarchy
return false;
if (decl.isNillable())
// because nillable needs JAXBElement to represent correctly
return false;
BIXSubstitutable bixSubstitutable = builder.getBindInfo(decl).get(BIXSubstitutable.class);
if (bixSubstitutable != null) {
// see https://jaxb.dev.java.net/issues/show_bug.cgi?id=289
// this customization forces non-collapsing behavior.
bixSubstitutable.markAsAcknowledged();
return false;
}
if (getGlobalBinding().isSimpleMode() && decl.isGlobal()) {
// in the simple mode, we do more aggressive optimization, and get rid of
// a complex type class if it's only used once from a global element
XSElementDecl referer = getSoleElementReferer(decl.getType());
if (referer != null) {
// I must be the sole referer
assert referer == decl;
return true;
}
}
if (!type.isLocal() || !type.isComplexType())
return false;
return true;
}
Aggregations