private TypeUse find( XSSimpleType type ) {
TypeUse r;
boolean noAutoEnum = false;
// check for user specified conversion
BindInfo info = builder.getBindInfo(type);
BIConversion conv = info.get(BIConversion.class);
if( conv!=null ) {
// a conversion was found
conv.markAsAcknowledged();
return conv.getTypeUse(type);
}
// look for enum customization, which is another user specified conversion
BIEnum en = info.get(BIEnum.class);
if( en!=null ) {
en.markAsAcknowledged();
if(!en.isMapped()) {
noAutoEnum = true;
} else {
// if an enum customization is specified, make sure
// the type is OK
if( !canBeMappedToTypeSafeEnum(type) ) {
getErrorReporter().error( en.getLocation(),
Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM );
getErrorReporter().error( type.getLocator(),
Messages.ERR_CANNOT_BE_TYPE_SAFE_ENUM_LOCATION );
// recover by ignoring this customization
return null;
}
// reference?
if(en.ref!=null) {
if(!JJavaName.isFullyQualifiedClassName(en.ref)) {
Ring.get(ErrorReceiver.class).error( en.getLocation(),
Messages.format(Messages.ERR_INCORRECT_CLASS_NAME, en.ref) );
// recover by ignoring @ref
return null;
}
return new CClassRef(model, type, en, info.toCustomizationList() );
}
// list and union cannot be mapped to a type-safe enum,
// so in this stage we can safely cast it to XSRestrictionSimpleType
return bindToTypeSafeEnum( (XSRestrictionSimpleType)type,