本文整理了Java中com.fasterxml.jackson.databind.introspect.AnnotatedMember
类的一些代码示例,展示了AnnotatedMember
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedMember
类的具体详情如下:
包路径:com.fasterxml.jackson.databind.introspect.AnnotatedMember
类名称:AnnotatedMember
[英]Intermediate base class for annotated entities that are members of a class; fields, methods and constructors. This is a superset of things that can represent logical properties as it contains constructors in addition to fields and methods.
[中]作为类成员的注释实体的中间基类;字段、方法和构造函数。这是可以表示逻辑属性的事物的超集,因为它除了包含字段和方法外还包含构造函数。
代码示例来源:origin: redisson/redisson
@Override
public <A extends Annotation> A getAnnotation(Class<A> acls) {
return (_member == null) ? null : _member.getAnnotation(acls);
}
代码示例来源:origin: redisson/redisson
throws JsonMappingException
Class<?> raw = type.getRawClass();
AnnotatedMember valueAccessor = beanDesc.findJsonValueAccessor();
if (valueAccessor != null) {
if (prov.canOverrideAccessModifiers()) {
ClassUtil.checkAndFixAccess(valueAccessor.getMember(),
prov.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS));
代码示例来源:origin: redisson/redisson
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
/* 27-Apr-2015, tatu: First things first; for JSON Schema introspection,
* Enum types that use `@JsonValue` are special (but NOT necessarily
* anything else that RETURNS an enum!)
* So we will need to add special
* handling here (see https://github.com/FasterXML/jackson-module-jsonSchema/issues/57
* for details).
*
* Note that meaning of JsonValue, then, is very different for Enums. Sigh.
*/
final JavaType type = _accessor.getType();
Class<?> declaring = _accessor.getDeclaringClass();
if ((declaring != null) && declaring.isEnum()) {
if (_acceptJsonFormatVisitorForEnum(visitor, typeHint, declaring)) {
return;
}
}
JsonSerializer<Object> ser = _valueSerializer;
if (ser == null) {
ser = visitor.getProvider().findTypedValueSerializer(type, false, _property);
if (ser == null) { // can this ever occur?
visitor.expectAnyFormat(typeHint);
return;
}
}
ser.acceptJsonFormatVisitor(visitor, type);
}
代码示例来源:origin: redisson/redisson
@Override
public String toString() {
return "(@JsonValue serializer for method " + _accessor.getDeclaringClass() + "#" + _accessor.getName() + ")";
}
代码示例来源:origin: apache/incubator-druid
@Override
public Object findInjectableValueId(AnnotatedMember m)
{
if (m.getAnnotation(JacksonInject.class) == null) {
return null;
}
Annotation guiceAnnotation = null;
for (Annotation annotation : m.annotations()) {
if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) {
guiceAnnotation = annotation;
break;
}
}
if (guiceAnnotation == null) {
if (m instanceof AnnotatedMethod) {
throw new IAE("Annotated methods don't work very well yet...");
}
return Key.get(m.getGenericType());
}
return Key.get(m.getGenericType(), guiceAnnotation);
}
}
代码示例来源:origin: redisson/redisson
/**
* Method used to locate the method of introspected class that
* implements {@link com.fasterxml.jackson.annotation.JsonAnyGetter}.
* If no such method exists null is returned.
* If more than one are found, an exception is thrown.
*/
@Override
public AnnotatedMember findAnyGetter() throws IllegalArgumentException
{
AnnotatedMember anyGetter = (_propCollector == null) ? null
: _propCollector.getAnyGetter();
if (anyGetter != null) {
/* For now let's require a Map; in future can add support for other
* types like perhaps Iterable<Map.Entry>?
*/
Class<?> type = anyGetter.getRawType();
if (!Map.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Invalid 'any-getter' annotation on method "+anyGetter.getName()+"(): return type is not instance of java.util.Map");
}
}
return anyGetter;
}
代码示例来源:origin: swagger-api/swagger-core
null;
final BeanDescription beanDesc = _mapper.getSerializationConfig().introspect(type);
JsonIdentityInfo jsonIdentityInfo = AnnotationsUtils.getAnnotation(JsonIdentityInfo.class, annotatedType.getCtxAnnotations());
if (jsonIdentityInfo == null) {
jsonIdentityInfo = type.getRawClass().getAnnotation(JsonIdentityInfo.class);
XML xml = resolveXml(beanDesc.getClassInfo(), annotatedType.getCtxAnnotations(), resolvedSchemaAnnotation);
if (xml != null) {
model.xml(xml);
final JsonProperty jsonPropertyAnn = propDef.getPrimaryMember().getAnnotation(JsonProperty.class);
if (jsonPropertyAnn == null || !jsonPropertyAnn.value().equals(propName)) {
if (member != null) {
java.lang.reflect.Member innerMember = member.getMember();
if (innerMember != null) {
String altName = innerMember.getName();
for (Annotation a : member.annotations()) {
annotationList.add(a);
JavaType propType = member.getType();
JsonUnwrapped uw = propMember.getAnnotation(JsonUnwrapped.class);
if (uw != null && uw.enabled()) {
final BeanDescription propBeanDesc = _mapper.getSerializationConfig().introspect(propType);
代码示例来源:origin: redisson/redisson
return prov.reportBadPropertyDefinition(_beanDesc, propDef, ClassUtil.exceptionMessage(e));
JavaType ct = serializationType.getContentType();
prov.reportBadPropertyDefinition(_beanDesc, propDef,
"serialization type "+serializationType+" has no content");
serializationType = serializationType.withContentTypeHandler(contentTypeSer);
ct = serializationType.getContentType();
AnnotatedMember accessor = propDef.getAccessor();
if (accessor == null) {
"could not determine property type");
Class<?> rawPropertyType = accessor.getRawType();
inclV = inclV.withOverrides(propDef.findInclusion());
am.fixAccess(_config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS));
valueToSuppress = am.getValue(defaultBean);
} catch (Exception e) {
_throwWrapped(e, propDef.getName(), defaultBean);
views = _beanDesc.findDefaultViews();
Object serDef = _annotationIntrospector.findNullSerializer(am);
代码示例来源:origin: redisson/redisson
Class<?> rawBase = (baseType == null) ? property.getRawType() : baseType.getRawClass();
Collection<NamedType> st = ai.findSubtypes(property);
if (st != null) {
for (NamedType nt : st) {
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
throws JsonMappingException
final PropertyName name = propDef.getFullName();
if (prov.canOverrideAccessModifiers()) {
accessor.fixAccess();
JavaType type = accessor.getType(typeContext);
BeanProperty.Std property = new BeanProperty.Std(name, type, propDef.getWrapperName(),
pb.getClassAnnotations(), accessor, propDef.getMetadata());
annotatedSerializer = prov.handlePrimaryContextualization(annotatedSerializer, property);
if (ClassUtil.isCollectionMapOrArray(type.getRawClass()) || type.isCollectionLikeType() || type.isMapLikeType()) {
contentTypeSer = findPropertyContentTypeSerializer(type, prov.getConfig(), accessor);
代码示例来源:origin: redisson/redisson
BeanDescription beanDesc = config.introspectClassAnnotations(keyType.getRawClass());
JsonSerializer<?> ser = null;
ser = defaultImpl;
if (ser == null) {
ser = StdKeySerializers.getStdKeySerializer(config, keyType.getRawClass(), false);
beanDesc = config.introspect(keyType);
AnnotatedMember am = beanDesc.findJsonValueAccessor();
if (am != null) {
final Class<?> rawType = am.getRawType();
JsonSerializer<?> delegate = StdKeySerializers.getStdKeySerializer(config,
rawType, true);
if (config.canOverrideAccessModifiers()) {
ClassUtil.checkAndFixAccess(am.getMember(),
config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS));
ser = StdKeySerializers.getFallbackKeySerializer(config, keyType.getRawClass());
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
throws JsonMappingException
final String name = propDef.getName();
if (prov.canOverrideAccessModifiers()) {
accessor.fixAccess();
JavaType type = accessor.getType(typeContext);
BeanProperty.Std property = new BeanProperty.Std(name, type, pb.getClassAnnotations(), accessor);
if (ClassUtil.isCollectionMapOrArray(type.getRawClass())) {
contentTypeSer = findPropertyContentTypeSerializer(type, prov.getConfig(), accessor);
TypeSerializer typeSer = findPropertyTypeSerializer(type, prov.getConfig(), accessor);
BeanPropertyWriter pbw = pb.buildWriter(propDef, type, annotatedSerializer,
typeSer, contentTypeSer, accessor, staticTyping);
代码示例来源:origin: redisson/redisson
if (beanDesc.getBeanClass() == Object.class) {
return prov.getUnknownTypeSerializer(Object.class);
final SerializationConfig config = prov.getConfig();
BeanSerializerBuilder builder = constructBeanSerializerBuilder(beanDesc);
builder.setConfig(config);
prov.getAnnotationIntrospector().findAndAddVirtualProperties(config, beanDesc.getClassInfo(), props);
builder.setFilterId(findFilterId(config, beanDesc));
AnnotatedMember anyGetter = beanDesc.findAnyGetter();
if (anyGetter != null) {
JavaType type = anyGetter.getType();
boolean staticTyping = config.isEnabled(MapperFeature.USE_STATIC_TYPING);
JavaType valueType = type.getContentType();
TypeSerializer typeSer = createTypeSerializer(config, valueType);
PropertyName name = PropertyName.construct(anyGetter.getName());
BeanProperty.Std anyProp = new BeanProperty.Std(name, valueType, null,
anyGetter, PropertyMetadata.STD_OPTIONAL);
builder.setAnyGetter(new AnyGetterWriter(anyProp, anyGetter, anySer));
代码示例来源:origin: redisson/redisson
JavaType t = _accessor.getType();
if (provider.isEnabled(MapperFeature.USE_STATIC_TYPING) || t.isFinal()) {
ser = provider.findPrimaryPropertySerializer(t, property);
boolean forceTypeInformation = isNaturalTypeWithStdHandling(t.getRawClass(), ser);
return withResolved(property, ser, forceTypeInformation);
ser = provider.handlePrimaryContextualization(ser, property);
return withResolved(property, ser, _forceTypeInformation);
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
if (beanDesc.getBeanClass() == Object.class) {
return prov.getUnknownTypeSerializer(Object.class);
final SerializationConfig config = prov.getConfig();
BeanSerializerBuilder builder = constructBeanSerializerBuilder(beanDesc);
builder.setConfig(config);
prov.getAnnotationIntrospector().findAndAddVirtualProperties(config, beanDesc.getClassInfo(), props);
builder.setFilterId(findFilterId(config, beanDesc));
AnnotatedMember anyGetter = beanDesc.findAnyGetter();
if (anyGetter != null) {
if (config.canOverrideAccessModifiers()) {
anyGetter.fixAccess();
JavaType type = anyGetter.getType(beanDesc.bindingsForBeanType());
boolean staticTyping = config.isEnabled(MapperFeature.USE_STATIC_TYPING);
JavaType valueType = type.getContentType();
TypeSerializer typeSer = createTypeSerializer(config, valueType);
PropertyName name = new PropertyName(anyGetter.getName());
BeanProperty.Std anyProp = new BeanProperty.Std(name, valueType, null,
beanDesc.getClassAnnotations(), anyGetter, PropertyMetadata.STD_OPTIONAL);
builder.setAnyGetter(new AnyGetterWriter(anyProp, anyGetter, anySer));
代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-csv
BeanDescription beanDesc = getSerializationConfig().introspect(pojoType);
for (BeanPropertyDefinition prop : beanDesc.findProperties()) {
if (!prop.couldSerialize()) {
continue;
AnnotatedMember m = prop.getPrimaryMember();
if (m != null) {
NameTransformer nextUnwrapper = intr.findUnwrappingNameTransformer(prop.getPrimaryMember());
if (nextUnwrapper != null) {
if (unwrapper != null) {
nextUnwrapper = NameTransformer.chainedTransformer(unwrapper, nextUnwrapper);
JavaType nextType = m.getType();
_addSchemaProperties(builder, intr, typed, nextType, nextUnwrapper);
continue;
builder.addColumn(name, _determineType(m.getRawType()));
} else {
builder.addColumn(name);
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
List<BeanPropertyDefinition> properties)
AnnotationIntrospector intr = config.getAnnotationIntrospector();
HashMap<Class<?>,Boolean> ignores = new HashMap<Class<?>,Boolean>();
Iterator<BeanPropertyDefinition> it = properties.iterator();
while (it.hasNext()) {
BeanPropertyDefinition property = it.next();
AnnotatedMember accessor = property.getAccessor();
if (accessor == null) {
it.remove();
continue;
Class<?> type = accessor.getRawType();
Boolean result = ignores.get(type);
if (result == null) {
BeanDescription desc = config.introspectClassAnnotations(type);
AnnotatedClass ac = desc.getClassInfo();
result = intr.isIgnorableType(ac);
代码示例来源:origin: redisson/redisson
throws JsonMappingException
final PropertyName name = propDef.getFullName();
JavaType type = accessor.getType();
BeanProperty.Std property = new BeanProperty.Std(name, type, propDef.getWrapperName(),
accessor, propDef.getMetadata());
annotatedSerializer = prov.handlePrimaryContextualization(annotatedSerializer, property);
if (type.isContainerType() || type.isReferenceType()) {
contentTypeSer = findPropertyContentTypeSerializer(type, prov.getConfig(), accessor);
TypeSerializer typeSer = findPropertyTypeSerializer(type, prov.getConfig(), accessor);
return pb.buildWriter(prov, propDef, type, annotatedSerializer,
typeSer, contentTypeSer, accessor, staticTyping);
代码示例来源:origin: swagger-api/swagger-core
javaType = mapper.constructType(type.getType());
final BeanDescription beanDesc = mapper.getSerializationConfig().introspect(javaType);
for (BeanPropertyDefinition def : beanDesc.findProperties()) {
final String name = def.getName();
if (name != null && name.equals(propertyName)) {
final AnnotatedMember propMember = def.getPrimaryMember();
final JavaType propType = propMember.getType();
if (PrimitiveType.fromType(propType) != null) {
return PrimitiveType.createProperty(propType);
} else {
List<Annotation> list = new ArrayList<>();
for (Annotation a : propMember.annotations()) {
list.add(a);
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
protected CsvSchema _schemaFor(JavaType pojoType, LRUMap<JavaType,CsvSchema> schemas, boolean typed)
{
synchronized (schemas) {
CsvSchema s = schemas.get(pojoType);
if (s != null) {
return s;
}
}
BeanDescription beanDesc = getSerializationConfig().introspect(pojoType);
CsvSchema.Builder builder = CsvSchema.builder();
for (BeanPropertyDefinition prop : beanDesc.findProperties()) {
// ignore setter-only properties:
if (prop.couldSerialize()) {
if (typed) {
builder.addColumn(prop.getName(), _determineType(prop.getAccessor().getRawType()));
} else {
builder.addColumn(prop.getName());
}
}
}
CsvSchema result = builder.build();
synchronized (schemas) {
schemas.put(pojoType, result);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!