ConfigurationBeanLoader will ignore unexpected properties on instances.
If no method has been annotated to accept that property, don't complain, don't throw an exception, just continue.
This commit is contained in:
parent
9e3ac4fb54
commit
8fbfc6d4ff
2 changed files with 27 additions and 36 deletions
|
@ -70,7 +70,8 @@ public class WrappedInstance<T> {
|
|||
*/
|
||||
public void checkCardinality(Set<PropertyStatement> propertyStatements)
|
||||
throws CardinalityException {
|
||||
Map<String, Integer> statementCounts = countPropertyStatementsByPredicateUri(propertyStatements);
|
||||
Map<String, Integer> statementCounts = countPropertyStatementsByPredicateUri(
|
||||
propertyStatements);
|
||||
for (PropertyMethod pm : propertyMethods.values()) {
|
||||
Integer c = statementCounts.get(pm.getPropertyUri());
|
||||
int count = (c == null) ? 0 : c;
|
||||
|
@ -109,12 +110,11 @@ public class WrappedInstance<T> {
|
|||
*/
|
||||
public void setProperties(ConfigurationBeanLoader loader,
|
||||
Collection<PropertyStatement> propertyStatements)
|
||||
throws PropertyTypeException, NoSuchPropertyMethodException,
|
||||
ConfigurationBeanLoaderException {
|
||||
throws PropertyTypeException, ConfigurationBeanLoaderException {
|
||||
for (PropertyStatement ps : propertyStatements) {
|
||||
PropertyMethod pm = propertyMethods.get(ps.getPredicateUri());
|
||||
if (pm == null) {
|
||||
throw new NoSuchPropertyMethodException(ps);
|
||||
continue; // No method for this property? Ignore it.
|
||||
}
|
||||
pm.confirmCompatible(ps);
|
||||
|
||||
|
@ -141,7 +141,8 @@ public class WrappedInstance<T> {
|
|||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException e) {
|
||||
throw new ValidationFailedException(
|
||||
"Error executing validation method '" + method + "'", e);
|
||||
"Error executing validation method '" + method + "'",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,12 +166,6 @@ public class WrappedInstance<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public static class NoSuchPropertyMethodException extends Exception {
|
||||
public NoSuchPropertyMethodException(PropertyStatement ps) {
|
||||
super("No property method for '" + ps.getPredicateUri() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public static class CardinalityException extends Exception {
|
||||
public CardinalityException(String message) {
|
||||
super(message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue