本文整理了Java中com.fasterxml.jackson.databind.introspect.Annotated
类的一些代码示例,展示了Annotated
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotated
类的具体详情如下:
包路径:com.fasterxml.jackson.databind.introspect.Annotated
类名称:Annotated
[英]Shared base class used for anything on which annotations (included within a AnnotationMap).
[中]共享基类,用于包含注释(包含在AnnotationMap中)的任何对象。
代码示例来源:origin: Netflix/eureka
@Override
public Object findFilterId(Annotated a) {
if (Map.class.isAssignableFrom(a.getRawType())) {
return filterName;
}
return super.findFilterId(a);
}
});
代码示例来源:origin: requery/requery
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;
}
}
代码示例来源:origin: redisson/redisson
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);
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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);
代码示例来源:origin: redisson/redisson
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();
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
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);
代码示例来源:origin: requery/requery
@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);
代码示例来源:origin: Nextdoor/bender
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);
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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);
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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) {
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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;
}
}
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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;
}
代码示例来源:origin: mongojack/mongojack
@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;
}
代码示例来源:origin: buremba/netty-rest
@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;
}
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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();
代码示例来源:origin: theonedev/onedev
@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);
}
}
代码示例来源:origin: redisson/redisson
@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;
}
代码示例来源:origin: swagger-api/swagger-core
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;
}
代码示例来源:origin: redisson/redisson
/**
* 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();
}
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
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;
}
内容来源于网络,如有侵权,请联系作者删除!