((ConfigBean) value).validate(errors, integrityCheckOnly);
}
}
}
else {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "' bc. it is not accessible via getMethod.",
new String[] { desc.getName() }));
}
}
catch (Exception e) {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "'.", new String[] { desc.getName() }));
}
}
else if (List.class.isAssignableFrom(desc.getPropertyType())) {
try {
Method readMethod = desc.getReadMethod();
if (readMethod != null) {
if (readMethod.getAnnotation(SkipValidation.class) == null) {
Object value = readMethod.invoke(this, new Object[0]);
if (value != null) {
Iterator it = ((List) value).iterator();
Type[] typeArguments = retrieveGenericsOfReturnType(readMethod);
while (it.hasNext()) {
Object listValue = it.next();
// check list value against generics
if (listValue != null) {
if (typeArguments != null && typeArguments.length > 0) {
Class typeArgClass = (Class) typeArguments[0];
if (!typeArgClass.isAssignableFrom(listValue.getClass())) {
errors
.add(new ValidationError("Unsupported type '" + listValue.getClass() + "' in list '" + desc.getName() + "'.",
new String[] { desc.getName() }));
}
}
}
if (listValue instanceof ConfigBean) {
((ConfigBean) listValue).validate(errors, integrityCheckOnly);
}
}
}
}
}
else {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "' bc. it is not accessible via getMethod.",
new String[] { desc.getName() }));
}
}
catch (Exception e) {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "'.", new String[] { desc.getName() }));
}
}
else if (Map.class.isAssignableFrom(desc.getPropertyType())) {
try {
Method readMethod = desc.getReadMethod();
if (readMethod != null) {
if (readMethod.getAnnotation(SkipValidation.class) == null) {
Object value = readMethod.invoke(this, new Object[0]);
if (value != null) {
Type[] typeArguments = retrieveGenericsOfReturnType(readMethod);
Iterator it = ((Map) value).keySet().iterator();
while (it.hasNext()) {
Object mapKey = it.next();
Object mapValue = ((Map) value).get(mapKey);
// check mapKey against generics
if (mapKey != null) {
if (typeArguments != null && typeArguments.length > 0) {
Class typeArgClass = (Class) typeArguments[0];
if (!typeArgClass.isAssignableFrom(mapKey.getClass())) {
errors
.add(new ValidationError("Unsupported keytype '" + mapKey.getClass() + "' in map '" + desc.getName() + "'.",
new String[] { desc.getName() }));
}
}
}
// check mapValue against generics
if (mapValue != null) {
if (typeArguments != null && typeArguments.length > 1) {
Class typeArgClass = (Class) typeArguments[1];
if (!typeArgClass.isAssignableFrom(mapValue.getClass())) {
errors.add(new ValidationError("Unsupported value '" + mapValue.getClass() + "' in map '" + desc.getName() + "' for key '" + mapKey + "'.",
new String[] { desc.getName() }));
}
}
}
if (mapValue instanceof ConfigBean) {
((ConfigBean) mapValue).validate(errors, integrityCheckOnly);
}
}
}
}
}
else {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "' bc. it is not accessible via getMethod.",
new String[] { desc.getName() }));
}
}
catch (Exception e) {
errors.add(new ValidationError("Unable to validate field '" + desc.getName() + "' of '" + this.getClass().getName() + "'.", new String[] { desc.getName() }));
}
}
}
}
catch (IntrospectionException e) {