if (child != null) {
return;
}
if (binding instanceof ComplexBinding) {
ComplexBinding complex = (ComplexBinding) binding;
if (binding.getType() == null) {
LOGGER.warning("Binding for: " + binding.getTarget() + " does not declare type");
}
Object parent = this.parent;
if (parent != null && (binding.getType() != null)
&& !binding.getType().isAssignableFrom(parent.getClass())) {
LOGGER.fine(parent + " (" + parent.getClass().getName() + ") "
+ " is not of type " + binding.getType().getName());
//try to convert
Object converted = Converters.convert(parent, binding.getType());
if (converted != null) {
parent = converted;
} else {
LOGGER.fine("Could not convert " + parent + " to "
+ binding.getType().getName());
// For complex feature, if the feature can't be converted to the binding type,
// exit the route to avoid ClassCastException raised in
// child = complex.getProperty(parent, name);
// For example, MeasureTypeBinding.getProperty(parent, name) throws
// ClassCastException when 'uom' is not set.
if (parent instanceof ComplexAttributeImpl) {
return;
}
}
}
try {
child = complex.getProperty(parent, name);
} catch (Exception e) {
throw new RuntimeException("Failed to get property: " + name, e);
}
}
}