private static void populateManagedPropertyFromProperty(Property property, PropertyDefinition propertyDefinition,
@NotNull
ManagedProperty managedProperty, @Nullable
PropertySimple customProperty) {
// See if there is a custom adapter defined for this property.
PropertyAdapter propertyAdapter = PropertyAdapterFactory.getCustomPropertyAdapter(customProperty);
MetaValue metaValue = managedProperty.getValue();
if (metaValue != null) {
LOG.trace("Populating existing MetaValue of type " + metaValue.getMetaType() + " from RHQ property "
+ property + " with definition " + propertyDefinition + "...");
if (propertyAdapter == null) {
propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaValue);
}
propertyAdapter.populateMetaValueFromProperty(property, metaValue, propertyDefinition);
} else {
MetaType metaType = managedProperty.getMetaType();
if (propertyAdapter == null) {
propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaType);
}
LOG.trace("Converting property " + property + " with definition " + propertyDefinition
+ " to MetaValue of type " + metaType + "...");
metaValue = propertyAdapter.convertToMetaValue(property, propertyDefinition, metaType);
managedProperty.setValue(metaValue);
}
}