DATACMNS-1173 - Fixed value lookup of AnnotationRevisionMetadata.

Fixed handling of absent values. Minor refactorings. More unit tests.
This commit is contained in:
Oliver Gierke
2017-09-25 09:56:31 +02:00
parent 041c18bef9
commit 65e21344ac
3 changed files with 89 additions and 7 deletions

View File

@@ -85,9 +85,9 @@ public class AnnotationRevisionMetadata<N extends Number & Comparable<N>> implem
return Lazy.of(() -> {
AnnotationDetectionFieldCallback numberCallback = new AnnotationDetectionFieldCallback(annotationType);
ReflectionUtils.doWithFields(entity.getClass(), numberCallback);
return numberCallback.getValue(entity);
AnnotationDetectionFieldCallback callback = new AnnotationDetectionFieldCallback(annotationType);
ReflectionUtils.doWithFields(entity.getClass(), callback);
return Optional.ofNullable(callback.getValue(entity));
});
}
}

View File

@@ -40,8 +40,8 @@ public interface RevisionMetadata<N extends Number & Comparable<N>> {
* @throws IllegalStateException if no revision number is available.
*/
default N getRequiredRevisionNumber() {
return getRevisionNumber()
.orElseThrow(() -> new IllegalStateException(String.format("No revision number found on %s!", getDelegate())));
return getRevisionNumber().orElseThrow(
() -> new IllegalStateException(String.format("No revision number found on %s!", (Object) getDelegate())));
}
/**
@@ -58,8 +58,8 @@ public interface RevisionMetadata<N extends Number & Comparable<N>> {
* @throw IllegalStateException if no revision date is available.
*/
default LocalDateTime getRequiredRevisionDate() {
return getRevisionDate()
.orElseThrow(() -> new IllegalStateException(String.format("No revision date found on %s!", getDelegate())));
return getRevisionDate().orElseThrow(
() -> new IllegalStateException(String.format("No revision date found on %s!", (Object) getDelegate())));
}
/**