Search in sources :

Example 1 with TypedProperty

use of com.synopsys.integration.configuration.property.base.TypedProperty in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationHelpContext method findPropertyParseErrors.

public Map<String, List<String>> findPropertyParseErrors(List<Property> knownProperties) {
    Map<String, List<String>> exceptions = new HashMap<>();
    for (Property property : knownProperties) {
        if (property.getClass().isAssignableFrom(TypedProperty.class)) {
            // TODO: Can we do this without reflection?
            Optional<ValueParseException> exception = propertyConfiguration.getPropertyException((TypedProperty) property);
            if (exception.isPresent()) {
                List<String> propertyExceptions = exceptions.getOrDefault(property.getKey(), new ArrayList<>());
                if (StringUtils.isNotBlank(exception.get().getMessage())) {
                    propertyExceptions.add(exception.get().getMessage());
                } else {
                    propertyExceptions.add(exception.get().toString());
                }
                exceptions.put(property.getKey(), propertyExceptions);
            }
        }
    }
    return exceptions;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Property(com.synopsys.integration.configuration.property.Property) TypedProperty(com.synopsys.integration.configuration.property.base.TypedProperty) ValueParseException(com.synopsys.integration.configuration.parse.ValueParseException)

Aggregations

ValueParseException (com.synopsys.integration.configuration.parse.ValueParseException)1 Property (com.synopsys.integration.configuration.property.Property)1 TypedProperty (com.synopsys.integration.configuration.property.base.TypedProperty)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1