Skip to content

Commit e8b2db8

Browse files
committed
DATACMNS-305 - Added toString() methods to PersistentProperty implementations.
1 parent fd91313 commit e8b2db8

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/main/java/org/springframework/data/mapping/model/AbstractPersistentProperty.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,13 @@ public boolean equals(Object obj) {
309309
public int hashCode() {
310310
return this.field.hashCode();
311311
}
312+
313+
/*
314+
* (non-Javadoc)
315+
* @see java.lang.Object#toString()
316+
*/
317+
@Override
318+
public String toString() {
319+
return String.format("%s.%s : %s", getOwner().getType().getName(), getName(), getType().getName());
320+
}
312321
}

src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,26 @@ private <A extends Annotation> A cacheAndReturn(Class<? extends A> type, A annot
206206
protected boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
207207
return findAnnotation(annotationType) != null;
208208
}
209+
210+
/*
211+
* (non-Javadoc)
212+
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#toString()
213+
*/
214+
@Override
215+
public String toString() {
216+
217+
if (annotationCache.isEmpty()) {
218+
populateAnnotationCache(field);
219+
}
220+
221+
StringBuilder builder = new StringBuilder();
222+
223+
for (Annotation annotation : annotationCache.values()) {
224+
if (annotation != null) {
225+
builder.append(annotation.toString()).append(" ");
226+
}
227+
}
228+
229+
return builder.toString() + super.toString();
230+
}
209231
}

0 commit comments

Comments
 (0)