@Override public <A extends Annotation> A getAnnotation(Class<A> annotationType) { return this.typeDefinition.getAnnotation(annotationType); }
public boolean isHasTypeInfo() { return getAnnotation(JsonTypeInfo.class) != null; }
@Override public <A extends Annotation> A getAnnotation(Class<A> annotationType) { return this.typeDefinition.getAnnotation(annotationType); }
public boolean isHasTypeInfo() { return getAnnotation(JsonTypeInfo.class) != null; }
public JsonTypeInfo.Id getTypeIdType() { JsonTypeInfo.Id typeIdType = JsonTypeInfo.Id.CLASS; JsonTypeInfo typeInfo = getAnnotation(JsonTypeInfo.class); if (typeInfo != null) { typeIdType = typeInfo.use(); } return typeIdType; }
public JsonTypeInfo.As getTypeIdInclusion() { JsonTypeInfo.As inclusion = JsonTypeInfo.As.PROPERTY; JsonTypeInfo typeInfo = getAnnotation(JsonTypeInfo.class); if (typeInfo != null) { inclusion = typeInfo.include(); } return inclusion; }
public JsonTypeInfo.As getTypeIdInclusion() { JsonTypeInfo.As inclusion = JsonTypeInfo.As.PROPERTY; JsonTypeInfo typeInfo = getAnnotation(JsonTypeInfo.class); if (typeInfo != null) { inclusion = typeInfo.include(); } return inclusion; }
public boolean isHasSubTypes() { JsonSubTypes subtypes = getAnnotation(JsonSubTypes.class); return subtypes != null && subtypes.value().length > 0; }
public JsonTypeInfo.Id getTypeIdType() { JsonTypeInfo.Id typeIdType = JsonTypeInfo.Id.CLASS; JsonTypeInfo typeInfo = getAnnotation(JsonTypeInfo.class); if (typeInfo != null) { typeIdType = typeInfo.use(); } return typeIdType; }
public boolean isHasSubTypes() { JsonSubTypes subtypes = getAnnotation(JsonSubTypes.class); return subtypes != null && subtypes.value().length > 0; }
/** * The simple name for client-side code generation. * * @return The simple name for client-side code generation. */ public String getClientSimpleName() { String clientSimpleName = getSimpleName().toString(); ClientName clientName = getAnnotation(ClientName.class); if (clientName != null) { clientSimpleName = clientName.value(); } return clientSimpleName; }
/** * The simple name for client-side code generation. * * @return The simple name for client-side code generation. */ public String getClientSimpleName() { String clientSimpleName = getSimpleName().toString(); ClientName clientName = getAnnotation(ClientName.class); if (clientName != null) { clientSimpleName = clientName.value(); } return clientSimpleName; }
@Override public String getLabel() { String label = this.typeDefinition.getSimpleName().toString(); JsonRootName rootName = this.typeDefinition.getAnnotation(JsonRootName.class); label = rootName == null ? label : rootName.value(); JavaDoc.JavaDocTagList tags = this.typeDefinition.getJavaDoc().get("label"); if (tags != null && tags.size() > 0) { String tag = tags.get(0).trim(); label = tag.isEmpty() ? label : tag; } Label labelInfo = this.typeDefinition.getAnnotation(Label.class); label = labelInfo == null ? label : labelInfo.value(); return label; }
@Override public String getLabel() { String label = this.typeDefinition.getSimpleName().toString(); JsonRootName rootName = this.typeDefinition.getAnnotation(JsonRootName.class); label = rootName == null ? label : rootName.value(); JavaDoc.JavaDocTagList tags = this.typeDefinition.getJavaDoc().get("label"); if (tags != null && tags.size() > 0) { String tag = tags.get(0).trim(); label = tag.isEmpty() ? label : tag; } Label labelInfo = this.typeDefinition.getAnnotation(Label.class); label = labelInfo == null ? label : labelInfo.value(); return label; }
public Map<String, DecoratedTypeMirror> getSubTypes() { Map<String, DecoratedTypeMirror> subtypes = null; JsonSubTypes info = getAnnotation(JsonSubTypes.class); if (info != null) { subtypes = new TreeMap<>();
public Map<String, DecoratedTypeMirror> getSubTypes() { Map<String, DecoratedTypeMirror> subtypes = null; JsonSubTypes info = getAnnotation(JsonSubTypes.class); if (info != null) { subtypes = new TreeMap<>();
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }