public class ConfigurationUtility
{
public static PropertyDefinition getPropertyDefinitionForProperty(Property property,
ConfigurationDefinition configurationDefinition) {
LinkedList<Property> propertyHierarchy = getPropertyHierarchy(property);
Property topLevelProperty = propertyHierarchy.get(0);
PropertyDefinition propertyDefinition =
configurationDefinition.getPropertyDefinitions().get(topLevelProperty.getName());
for (int i = 1; i < propertyHierarchy.size(); i++)
{
Property subProperty = propertyHierarchy.get(i);
if (propertyDefinition instanceof PropertyDefinitionMap) {
propertyDefinition = ((PropertyDefinitionMap)propertyDefinition).get(subProperty.getName());
} else if (propertyDefinition instanceof PropertyDefinitionList) {
propertyDefinition = ((PropertyDefinitionList)propertyDefinition).getMemberDefinition();
}
}
return propertyDefinition;