if(owner == null) { throw new IllegalArgumentException("owner"); }
if(metaModel == null) { throw new IllegalArgumentException("metaModel"); }
if(StringUtils.isEmpty(this._alias))
{
throw new ValidationException(new RequiredAttributeError("Alias"));
}
ComponentType compType = owner.getMeta();
// Bind by alias first
PropertyTypeUsage propUsage = compType.tryGetPropertyUsage(this._alias);
if(propUsage == null)
{
// Only then bind by name
propUsage = compType.tryGetPropertyUsageByName(this._alias);
}
if(propUsage != null)
{
ExpectedPropertyBinding.Builder builder = new ExpectedPropertyBinding.Builder();
builder
.setPropertyUsage(propUsage)
.setValue(this.getValue());
return builder.build(owner, metaModel);
}
// Then try to bind by name to a global property
PropertyType prop = metaModel.tryGetPropertyType(this._alias);
if(prop != null)
{
ExtensionPropertyBinding.Builder builder = new ExtensionPropertyBinding.Builder();
// HACK: CCC V1 properties must be made to look like when they were defined
boolean isCCC = this._alias.startsWith("ccc");
String alias = isCCC ?
Utils.toFirstLowerCase(this._alias.substring(3)) :
this._alias;
builder
.setAlias(alias)
.setProperty(prop)
.setValue(this.getValue());
return builder.build(owner, metaModel);
}
throw new ValidationException(
new ComponentUnresolvedPropertyBindingError(
this._alias,
owner.getId(),
owner.getMeta().getLabel()));
}