本文整理了Java中com.fasterxml.jackson.databind.introspect.Annotated.getAnnotation()
方法的一些代码示例,展示了Annotated.getAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotated.getAnnotation()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.introspect.Annotated
类名称:Annotated
方法名:getAnnotation
暂无
代码示例来源: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: redisson/redisson
/**
* Method that should be used by sub-classes for ALL
* annotation access;
* overridable so
* that sub-classes may, if they choose to, mangle actual access to
* block access ("hide" annotations) or perhaps change it.
*<p>
* Default implementation is simply:
*<code>
* return annotated.getAnnotation(annoClass);
*</code>
*
* @since 2.5
*/
protected <A extends Annotation> A _findAnnotation(Annotated annotated,
Class<A> annoClass) {
return annotated.getAnnotation(annoClass);
}
代码示例来源:origin: swagger-api/swagger-core
public static io.swagger.v3.oas.annotations.media.Schema getSchemaAnnotation(Annotated a) {
if (a == null) {
return null;
}
io.swagger.v3.oas.annotations.media.ArraySchema arraySchema = a.getAnnotation(io.swagger.v3.oas.annotations.media.ArraySchema.class);
if (arraySchema != null) {
return arraySchema.schema();
} else {
return a.getAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
}
}
代码示例来源:origin: redisson/redisson
@Override
public Boolean findTransient(Annotated a) {
Transient t = a.getAnnotation(Transient.class);
if (t != null) {
return t.value();
}
return null;
}
代码示例来源:origin: swagger-api/swagger-core
@Override
public String findPropertyDescription(Annotated a) {
Schema model = a.getAnnotation(Schema.class);
if (model != null && !"".equals(model.description())) {
return model.description();
}
return null;
}
代码示例来源:origin: swagger-api/swagger-core
@Override
public List<NamedType> findSubtypes(Annotated a) {
Schema schema = a.getAnnotation(Schema.class);
if (schema == null) {
final ArraySchema arraySchema = a.getAnnotation(ArraySchema.class);
if (arraySchema != null) {
schema = arraySchema.schema();
}
}
if (AnnotationsUtils.hasSchemaAnnotation(schema)) {
final Class<?>[] classes = schema.subTypes();
final List<NamedType> names = new ArrayList<>(classes.length);
for (Class<?> subType : classes) {
names.add(new NamedType(subType));
}
if (!names.isEmpty()) {
return names;
}
}
return Collections.emptyList();
}
代码示例来源:origin: swagger-api/swagger-core
protected ExternalDocumentation resolveExternalDocumentation(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
ExternalDocumentation external = null;
if (a != null) {
io.swagger.v3.oas.annotations.ExternalDocumentation externalDocumentation = a.getAnnotation(io.swagger.v3.oas.annotations.ExternalDocumentation.class);
external = resolveExternalDocumentation(externalDocumentation);
}
if (external == null) {
if (schema != null) {
external = resolveExternalDocumentation(schema.externalDocs());
}
}
return external;
}
代码示例来源:origin: swagger-api/swagger-core
/**
* Applies annotations to property's {@link XML} definition.
*
* @param member annotations provider
* @param property property instance to be updated
*/
public static void apply(Annotated member, Annotation[] annotations, Schema property) {
XmlElementWrapper wrapper = member.getAnnotation(XmlElementWrapper.class);
if (wrapper == null) {
wrapper = AnnotationsUtils.getAnnotation(XmlElementWrapper.class, annotations);
}
XmlAttribute attr = member.getAnnotation(XmlAttribute.class);
if (attr == null) {
attr = AnnotationsUtils.getAnnotation(XmlAttribute.class, annotations);
}
XmlElement elem = member.getAnnotation(XmlElement.class);
if (elem == null) {
elem = AnnotationsUtils.getAnnotation(XmlElement.class, annotations);
}
if (wrapper != null) {
applyElement(wrapper, property);
} else if (elem != null) {
applyElement(elem, property);
} else if (attr != null && isAttributeAllowed(property)) {
applyAttribute(attr, property);
}
}
代码示例来源: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: 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: swagger-api/swagger-core
protected XML resolveXml(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
// if XmlRootElement annotation, construct an Xml object and attach it to the model
XmlRootElement rootAnnotation = null;
if (a != null) {
rootAnnotation = a.getAnnotation(XmlRootElement.class);
}
if (rootAnnotation == null) {
if (annotations != null) {
for (Annotation ann: annotations) {
if (ann instanceof XmlRootElement) {
rootAnnotation = (XmlRootElement)ann;
break;
}
}
}
}
if (rootAnnotation != null && !"".equals(rootAnnotation.name()) && !"##default".equals(rootAnnotation.name())) {
XML xml = new XML().name(rootAnnotation.name());
if (rootAnnotation.namespace() != null && !"".equals(rootAnnotation.namespace()) && !"##default".equals(rootAnnotation.namespace())) {
xml.namespace(rootAnnotation.namespace());
}
return xml;
}
return null;
}
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
@Override
public JsonFormat.Value findFormat(Annotated m) {
/* [jaxb-annotations#33]: Use @XmlEnum value (Class) to indicate format,
* iff it makes sense
*/
if (m instanceof AnnotatedClass) {
XmlEnum ann = m.getAnnotation(XmlEnum.class);
if (ann != null) {
Class<?> type = ann.value();
if (type == String.class || type.isEnum()) {
return FORMAT_STRING;
}
if (Number.class.isAssignableFrom(type)) {
return FORMAT_INT;
}
}
}
return null;
}
代码示例来源: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;
}
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
@Override
public ObjectIdInfo findObjectReferenceInfo(Annotated ann, ObjectIdInfo base)
{
if (!_ignoreXmlIDREF) {
XmlIDREF idref = ann.getAnnotation(XmlIDREF.class);
/* JAXB makes XmlIDREF mean "always as id", as far as I know.
* May need to make it configurable in future, but for not that
* is fine...
*/
if (idref != null) {
if (base == null) {
base = ObjectIdInfo.empty();
}
base = base.withAlwaysAsId(true);
}
}
return base;
}
代码示例来源: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
boolean includePackage, boolean includeClass, boolean includeSuperclasses)
A annotation = annotated.getAnnotation(annotationClass);
if (annotation != null) {
return annotation;
代码示例来源:origin: com.fasterxml.jackson.module/jackson-module-jaxb-annotations
XmlSeeAlso ann = a.getAnnotation(XmlSeeAlso.class);
if (ann != null) {
if (result == null) {
代码示例来源: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) {
代码示例来源:origin: FasterXML/jackson-dataformat-xml
@Override
public Boolean isOutputAsAttribute(Annotated ann)
{
JacksonXmlProperty prop = ann.getAnnotation(JacksonXmlProperty.class);
if (prop != null) {
return prop.isAttribute() ? Boolean.TRUE : Boolean.FALSE;
}
return null;
}
代码示例来源:origin: FasterXML/jackson-dataformat-xml
@Override
public Boolean isOutputAsText(Annotated ann)
{
JacksonXmlText prop = ann.getAnnotation(JacksonXmlText.class);
if (prop != null) {
return prop.value() ? Boolean.TRUE : Boolean.FALSE;
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!