Skip to content

Commit f6aef5a

Browse files
Use getAnnotationRecursive for JsonIdentity handling (#946)
1 parent b72681d commit f6aef5a

File tree

1 file changed

+2
-16
lines changed
  • typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser

1 file changed

+2
-16
lines changed

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Jackson2Parser.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ private static Integer getCreatorIndex(BeanProperty beanProperty) {
365365
}
366366
}
367367

368-
private <T extends Annotation> T findClassAnnotation(Class<?> cls, Class<T> annotation) {
369-
T identityInfo = cls.getAnnotation(annotation);
370-
371-
if (identityInfo == null) {
372-
Class<?> parent = cls.getSuperclass();
373-
374-
if (parent != null) {
375-
return findClassAnnotation(parent, annotation);
376-
}
377-
}
378-
379-
return identityInfo;
380-
}
381-
382368
// @JsonIdentityInfo and @JsonIdentityReference
383369
private Type processIdentity(Type propertyType, BeanProperty beanProperty) {
384370

@@ -387,13 +373,13 @@ private Type processIdentity(Type propertyType, BeanProperty beanProperty) {
387373
final Class<?> cls = clsT != null ? clsT : clsW;
388374

389375
if (cls != null) {
390-
final JsonIdentityInfo identityInfoC = this.findClassAnnotation(cls, JsonIdentityInfo.class);
376+
final JsonIdentityInfo identityInfoC = getAnnotationRecursive(cls, JsonIdentityInfo.class).getValue2();
391377
final JsonIdentityInfo identityInfoP = beanProperty.getAnnotation(JsonIdentityInfo.class);
392378
final JsonIdentityInfo identityInfo = identityInfoP != null ? identityInfoP : identityInfoC;
393379
if (identityInfo == null) {
394380
return null;
395381
}
396-
final JsonIdentityReference identityReferenceC = this.findClassAnnotation(cls, JsonIdentityReference.class);
382+
final JsonIdentityReference identityReferenceC = getAnnotationRecursive(cls, JsonIdentityReference.class).getValue2();
397383
final JsonIdentityReference identityReferenceP = beanProperty.getAnnotation(JsonIdentityReference.class);
398384
final JsonIdentityReference identityReference = identityReferenceP != null ? identityReferenceP : identityReferenceC;
399385
final boolean alwaysAsId = identityReference != null && identityReference.alwaysAsId();

0 commit comments

Comments
 (0)