@@ -76,18 +76,37 @@ public Optional<N> getRevisionNumber() {
76
76
@ Deprecated
77
77
public Optional <LocalDateTime > getRevisionDate () {
78
78
79
- return revisionDate .get ().map (this ::convertToLocalDateTime );
79
+ return revisionDate .get ().map (AnnotationRevisionMetadata ::convertToLocalDateTime );
80
80
}
81
81
82
82
/*
83
83
* (non-Javadoc)
84
84
* @see org.springframework.data.history.RevisionMetadata#getRevisionDate()
85
85
*/
86
86
public Optional <Instant > getRevisionInstant () {
87
- return revisionDate .get ().map (this ::convertToInstant );
87
+ return revisionDate .get ().map (AnnotationRevisionMetadata ::convertToInstant );
88
88
}
89
89
90
- private LocalDateTime convertToLocalDateTime (TemporalAccessor temporalAccessor ) {
90
+ /*
91
+ * (non-Javadoc)
92
+ * @see org.springframework.data.repository.history.RevisionMetadata#getDelegate()
93
+ */
94
+ @ SuppressWarnings ("unchecked" )
95
+ public <T > T getDelegate () {
96
+ return (T ) entity ;
97
+ }
98
+
99
+ private static <T > Lazy <Optional <T >> detectAnnotation (Object entity , Class <? extends Annotation > annotationType ) {
100
+
101
+ return Lazy .of (() -> {
102
+
103
+ AnnotationDetectionFieldCallback callback = new AnnotationDetectionFieldCallback (annotationType );
104
+ ReflectionUtils .doWithFields (entity .getClass (), callback );
105
+ return Optional .ofNullable (callback .getValue (entity ));
106
+ });
107
+ }
108
+
109
+ private static LocalDateTime convertToLocalDateTime (TemporalAccessor temporalAccessor ) {
91
110
92
111
if (temporalAccessor instanceof LocalDateTime ) {
93
112
return (LocalDateTime ) temporalAccessor ;
@@ -97,10 +116,10 @@ private LocalDateTime convertToLocalDateTime(TemporalAccessor temporalAccessor)
97
116
return LocalDateTime .ofInstant ((Instant ) temporalAccessor , ZoneOffset .systemDefault ());
98
117
}
99
118
100
- throw new IllegalArgumentException (String .format ("Can't convert %s to LocalDateTime" , temporalAccessor ));
119
+ throw new IllegalArgumentException (String .format ("Can't convert %s to LocalDateTime! " , temporalAccessor ));
101
120
}
102
121
103
- private Instant convertToInstant (TemporalAccessor temporalAccessor ) {
122
+ private static Instant convertToInstant (TemporalAccessor temporalAccessor ) {
104
123
105
124
if (temporalAccessor instanceof Instant ) {
106
125
return (Instant ) temporalAccessor ;
@@ -110,25 +129,6 @@ private Instant convertToInstant(TemporalAccessor temporalAccessor) {
110
129
return ((LocalDateTime ) temporalAccessor ).atZone (ZoneOffset .systemDefault ()).toInstant ();
111
130
}
112
131
113
- throw new IllegalArgumentException (String .format ("Can't convert %s to LocalDateTime" , temporalAccessor ));
114
- }
115
-
116
- /*
117
- * (non-Javadoc)
118
- * @see org.springframework.data.repository.history.RevisionMetadata#getDelegate()
119
- */
120
- @ SuppressWarnings ("unchecked" )
121
- public <T > T getDelegate () {
122
- return (T ) entity ;
123
- }
124
-
125
- private static <T > Lazy <Optional <T >> detectAnnotation (Object entity , Class <? extends Annotation > annotationType ) {
126
-
127
- return Lazy .of (() -> {
128
-
129
- AnnotationDetectionFieldCallback callback = new AnnotationDetectionFieldCallback (annotationType );
130
- ReflectionUtils .doWithFields (entity .getClass (), callback );
131
- return Optional .ofNullable (callback .getValue (entity ));
132
- });
132
+ throw new IllegalArgumentException (String .format ("Can't convert %s to LocalDateTime!" , temporalAccessor ));
133
133
}
134
134
}
0 commit comments