#390 - ChangeLog - Add inheritance hierarchy check for @ChangeLog

This commit is contained in:
Robin Bygrave
2015-08-26 10:42:12 +12:00
parent f3e66c459a
commit aaefaa5dcd
3 changed files with 30 additions and 1 deletions
@@ -30,7 +30,7 @@ public class DefaultChangeLogRegister implements ChangeLogRegister {
@Override
public ChangeLogFilter getChangeFilter(Class<?> beanType) {
ChangeLog changeLog = beanType.getAnnotation(ChangeLog.class);
ChangeLog changeLog = getChangeLog(beanType);
if (changeLog == null) {
return null;
}
@@ -48,6 +48,20 @@ public class DefaultChangeLogRegister implements ChangeLogRegister {
return new UpdateFilter(insertModeInclude(changeLog.inserts()), updateProps);
}
/**
* Find and return the ChangeLog annotation in the inheritance hierarchy.
*/
private ChangeLog getChangeLog(Class<?> beanType) {
ChangeLog changeLog = beanType.getAnnotation(ChangeLog.class);
if (changeLog != null) {
return changeLog;
}
if (Object.class.equals(beanType.getSuperclass())) {
return null;
}
return getChangeLog(beanType.getSuperclass());
}
/**
* Return true if inserts should be included in the change log.
*/