@Override public Object findFilterId(Annotated a) { if (Map.class.isAssignableFrom(a.getRawType())) { return filterName; } return super.findFilterId(a); } });
private PropertyName getMappedName(Annotated annotated) { if (annotated.hasAnnotation(Table.class)) { Table table = annotated.getAnnotation(Table.class); return new PropertyName(table.name()); } if (annotated.hasAnnotation(View.class)) { View view = annotated.getAnnotation(View.class); return new PropertyName(view.name()); } else if (annotated.hasAnnotation(Column.class)) { Column column = annotated.getAnnotation(Column.class); return new PropertyName(column.name()); } else { return null; } }
final TypeFactory tf = config.getTypeFactory(); final JsonDeserialize jsonDeser = _findAnnotation(a, JsonDeserialize.class); final Class<?> valueClass = (jsonDeser == null) ? null : _classIfExplicit(jsonDeser.as()); if ((valueClass != null) && !type.hasRawClass(valueClass) && !_primitiveAndWrapper(type, valueClass)) { try { type = tf.constructSpecializedType(type, valueClass); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow type %s with annotation (value %s), from '%s': %s", type, valueClass.getName(), a.getName(), iae.getMessage()), iae); type = ((MapLikeType) type).withKeyType(keyType); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow key type of %s with concrete-type annotation (value %s), from '%s': %s", type, keyClass.getName(), a.getName(), iae.getMessage()), iae); type = type.withContentType(contentType); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow value type of %s with concrete-type annotation (value %s), from '%s': %s", type, contentClass.getName(), a.getName(), iae.getMessage()), iae);
if (baseType.getContentType() == null) { // non-container/-structured types, usually scalar: if (baseType.hasRawClass(deserClass)) { // no change return baseType; if (!baseType.getRawClass().isAssignableFrom(deserClass)) { return baseType; return tf.constructSpecializedType(baseType, deserClass); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow type %s with annotation (value %s), from '%s': %s", baseType, deserClass.getName(), a.getName(), iae.getMessage()), iae); return baseType.withContentType(contentType); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow type %s with annotation (value %s), from '%s': %s", baseType, deserClass.getName(), a.getName(), iae.getMessage()), iae);
throws JsonMappingException JavaType secondary = _annotationIntrospector.refineSerializationType(_config, a, declaredType); Class<?> serClass = secondary.getRawClass(); Class<?> rawDeclared = declaredType.getRawClass(); if (serClass.isAssignableFrom(rawDeclared)) { throw new IllegalArgumentException("Illegal concrete-type annotation for method '"+a.getName()+"': class "+serClass.getName()+" not a super-type of (declared) class "+rawDeclared.getName()); JsonSerialize.Typing typing = _annotationIntrospector.findSerializationTyping(a); if ((typing != null) && (typing != JsonSerialize.Typing.DEFAULT_TYPING)) { useStaticTyping = (typing == JsonSerialize.Typing.STATIC); return declaredType.withStaticTyping();
Class<?> serClass = _annotationIntrospector.findSerializationType(a); if (serClass != null) { Class<?> rawDeclared = declaredType.getRawClass(); if (serClass.isAssignableFrom(rawDeclared)) { declaredType = declaredType.widenBy(serClass); } else { throw new IllegalArgumentException("Illegal concrete-type annotation for method '"+a.getName()+"': class "+serClass.getName()+" not a super-type of (declared) class "+rawDeclared.getName()); JsonSerialize.Typing typing = _annotationIntrospector.findSerializationTyping(a); if (typing != null) { useStaticTyping = (typing == JsonSerialize.Typing.STATIC);
@Override public ObjectIdInfo findObjectIdInfo(Annotated annotated) { Class<?> rawClass = annotated.getType().getRawClass(); for (Type<?> type : model.getTypes()) { if (type.getClassType() == rawClass && type.getSingleKeyAttribute() != null) { return new ObjectIdInfo(new PropertyName(name), rawClass, ObjectIdGenerators.PropertyGenerator.class, EntityStoreResolver.class); return super.findObjectIdInfo(annotated);
Class<?> valueClass = findDeserializationType(a, type); if ((valueClass != null) && !type.hasRawClass(valueClass)) { try { type = tf.constructSpecializedType(type, valueClass); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow type %s with annotation (value %s), from '%s': %s", type, valueClass.getName(), a.getName(), iae.getMessage()), iae); type = ((MapLikeType) type).withKeyType(keyType); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow key type of %s with concrete-type annotation (value %s), from '%s': %s", type, keyClass.getName(), a.getName(), iae.getMessage()), iae); if (contentType != null) { // collection[like], map[like], array, reference type = type.withContentType(contentType); } catch (IllegalArgumentException iae) { throw new JsonMappingException(null, String.format("Failed to narrow value type of %s with concrete-type annotation (value %s), from '%s': %s", type, contentClass.getName(), a.getName(), iae.getMessage()), iae);
private PropertyName findJaxbPropertyName(Annotated ae, Class<?> aeType, String defaultName) XmlAttribute attribute = ae.getAnnotation(XmlAttribute.class); if (attribute != null) { return _combineNames(attribute.name(), attribute.namespace(), defaultName); XmlElement element = ae.getAnnotation(XmlElement.class); if (element != null) { return _combineNames(element.name(), element.namespace(), defaultName); XmlElementRef elementRef = ae.getAnnotation(XmlElementRef.class); boolean hasAName = (elementRef != null); if (hasAName) { return new PropertyName(Introspector.decapitalize(aeType.getSimpleName())); hasAName = ae.hasAnnotation(XmlElementWrapper.class) || ae.hasAnnotation(XmlElements.class) || ae.hasAnnotation(XmlValue.class);
result = new ArrayList<NamedType>(); for (XmlElement elem : elems.value()) { String name = elem.name(); if (MARKER_FOR_DEFAULT.equals(name)) name = null; result.add(new NamedType(elem.type(), name)); XmlSeeAlso ann = a.getAnnotation(XmlSeeAlso.class); if (ann != null) { if (result == null) {
protected Class<?> _getTypeFromXmlElement(Annotated a) { XmlElement annotation = findAnnotation(XmlElement.class, a, false, false, false); if (annotation != null) { // Further, JAXB has peculiar notion of declaring intermediate (and, for the // most part, useless) type... So basically we betterjust ignore type if there // is adapter annotation (we could check to see if intermediate type is compatible, // but let's not yet bother) if (a.getAnnotation(XmlJavaTypeAdapter.class) != null) { return null; } Class<?> type = annotation.type(); if (type != XmlElement.DEFAULT.class) { return type; } } return null; } }
protected Class<?> _doFindDeserializationType(Annotated a, JavaType baseType) { /* @XmlJavaTypeAdapter will complicate handling of type information; * basically we better just ignore type we might find here altogether in that case */ if (a.hasAnnotation(XmlJavaTypeAdapter.class)) { return null; } // false for class, package, super-class, since annotation can // only be attached to fields and methods XmlElement annotation = findAnnotation(XmlElement.class, a, false, false, false); if (annotation != null) { Class<?> type = annotation.type(); if (type != XmlElement.DEFAULT.class) { return type; } } return null; }
@Override public JsonDeserializer findContentDeserializer(Annotated am) { if (am.hasAnnotation(ObjectId.class)) { JavaType type = typeFactory.constructType(getTypeForAnnotated(am)); if (type.isCollectionLikeType()) { return findObjectIdDeserializer(type.containedType(0)); } else if (type.isMapLikeType()) { return findObjectIdDeserializer(type.containedType(1)); } } return null; }
@Override public PropertyName findNameForSerialization(Annotated a) { ApiParam model = a.getAnnotation(ApiParam.class); if (model != null && !"".equals(model.value())) { return new PropertyName(model.value()); } return null; }
boolean includePackage, boolean includeClass, boolean includeSuperclasses) A annotation = annotated.getAnnotation(annotationClass); if (annotation != null) { return annotation; memberClass = ((AnnotatedParameter) annotated).getDeclaringClass(); } else { AnnotatedElement annType = annotated.getAnnotated(); if (annType instanceof Member) { memberClass = ((Member) annType).getDeclaringClass();
@SuppressWarnings("unchecked") @Override public Object findSerializer(Annotated am) { if (am.hasAnnotation(ManyToOne.class)) { return new ManyToOneSerializer((Class<AbstractEntity>) am.getRawType()); } else { return super.findDeserializer(am); } }
@Override public Boolean hasCreatorAnnotation(Annotated a) { ConstructorProperties props = a.getAnnotation(ConstructorProperties.class); // 08-Nov-2015, tatu: One possible check would be to ensure there is at least // one name iff constructor has arguments. But seems unnecessary for now. if (props != null) { return Boolean.TRUE; } return null; }
protected String resolveDefaultValue(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) { if (schema != null) { if (!schema.defaultValue().isEmpty()) { return schema.defaultValue(); } } if (a == null) { return null; } XmlElement elem = a.getAnnotation(XmlElement.class); if (elem == null) { if (annotations != null) { for (Annotation ann: annotations) { if (ann instanceof XmlElement) { elem = (XmlElement)ann; break; } } } } if (elem != null) { if (!elem.defaultValue().isEmpty() && !"\u0000".equals(elem.defaultValue())) { return elem.defaultValue(); } } return null; }
/** * JDK declared generic type of the annotated element; definition * of what exactly this means depends on sub-class. Note that such type * cannot be reliably resolved without {@link TypeResolutionContext}, and * as a result use of this method was deprecated in Jackson 2.7: see * {@link #getType} for replacement. * * @deprecated Since 2.7 should instead use {@link #getType()}. To be removed from 2.9 */ @Deprecated public Type getGenericType() { return getRawType(); }
JsonInclude.Include _serializationInclusion(Annotated a, JsonInclude.Include defValue) { XmlElementWrapper w = a.getAnnotation(XmlElementWrapper.class); if (w != null) { if (w.nillable()) { return JsonInclude.Include.ALWAYS; } // [jaxb-annotations#52]: Allow specifying inclusion for `nillable=false` too if (_nonNillableInclusion != null) { return _nonNillableInclusion; } } XmlElement e = a.getAnnotation(XmlElement.class); if (e != null) { if (e.nillable()) { return JsonInclude.Include.ALWAYS; } // [jaxb-annotations#52]: Allow specifying inclusion for `nillable=false` too if (_nonNillableInclusion != null) { return _nonNillableInclusion; } } //better pass default value through, if no explicit direction indicating otherwise return defValue; }