Fixed getType
This commit is contained in:
parent
af24bde831
commit
a8e1b0da6e
|
@ -94,21 +94,27 @@ public class TypeMapper {
|
|||
public static String getType(Class<? extends Element> clz){
|
||||
String classSimpleName = clz.getSimpleName();
|
||||
String name = null;
|
||||
|
||||
if(!clz.isInterface()) {
|
||||
if(clz.isAnnotationPresent(JsonTypeName.class)) {
|
||||
JsonTypeName jsonTypeName = clz.getAnnotation(JsonTypeName.class);
|
||||
name = jsonTypeName.value();
|
||||
if(name==null || name.compareTo("")!=0) {
|
||||
if(name==null || name.compareTo("")==0) {
|
||||
throw new RuntimeException("Invalid annotation @JsonTypeName for type " + classSimpleName);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
if(clz.isAnnotationPresent(TypeMetadata.class)) {
|
||||
TypeMetadata typeMetadata = clz.getAnnotation(TypeMetadata.class);
|
||||
String typeMetadataName = typeMetadata.name();
|
||||
if(typeMetadataName!=null && typeMetadataName.compareTo("")!=0) {
|
||||
/*
|
||||
if(name!=null && typeMetadataName.compareTo(name)!=0) {
|
||||
throw new RuntimeException("Name in annotation @TypeMetadata differ from annotation in @JsonTypeName for type " + classSimpleName + ". Please be coerent");
|
||||
}
|
||||
*/
|
||||
return typeMetadataName;
|
||||
}else {
|
||||
throw new RuntimeException("Invalid Name in annotation @TypeMetadata for type " + classSimpleName);
|
||||
|
@ -116,6 +122,7 @@ public class TypeMapper {
|
|||
}else {
|
||||
throw new RuntimeException("You must provide @TypeMetadata for " + classSimpleName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getTypeDescription(Class<? extends Element> clz){
|
||||
|
|
Loading…
Reference in New Issue