当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedField类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.introspect.AnnotatedField的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedField类的具体用法?Java AnnotatedField怎么用?Java AnnotatedField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AnnotatedField类属于com.fasterxml.jackson.databind.introspect包,在下文中一共展示了AnnotatedField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPropertyType

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
@Nullable
private TypeToken<?> getPropertyType(TypeToken<?> beanType, Method readMethod, Method writeMethod,
    AnnotatedField field, ApiConfig config) {
  if (readMethod != null) {
    // read method's return type is the property type
    return ApiAnnotationIntrospector.getSchemaType(
        beanType.resolveType(readMethod.getGenericReturnType()), config);
  } else if (writeMethod != null) {
    Type[] paramTypes = writeMethod.getGenericParameterTypes();
    if (paramTypes.length == 1) {
      // write method's first parameter type is the property type
      return ApiAnnotationIntrospector.getSchemaType(
          beanType.resolveType(paramTypes[0]), config);
    }
  } else if (field != null) {
    return ApiAnnotationIntrospector.getSchemaType(
        beanType.resolveType(field.getGenericType()), config);
  }
  return null;
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:21,代码来源:JacksonResourceSchemaProvider.java

示例2: findNameForSerialization

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
@Override
public PropertyName findNameForSerialization(Annotated a) {
	if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
		return super.findNameForSerialization(a);
	}

	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && !property.name().isEmpty()) {
		return new PropertyName(property.name());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && !component.name().isEmpty()) {
		return new PropertyName(component.name());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && !properties.name().isEmpty()) {
		return new PropertyName(properties.name());
	}

	return PropertyName.USE_DEFAULT;
}
 
开发者ID:aureliano,项目名称:evt-bridge,代码行数:24,代码来源:ElasticSearchAnnotationIntrospector.java

示例3: findNameForDeserialization

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
@Override
public PropertyName findNameForDeserialization(Annotated a) {
	if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
		return super.findNameForDeserialization(a);
	}

	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && !property.name().isEmpty()) {
		return new PropertyName(property.name());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && !component.name().isEmpty()) {
		return new PropertyName(component.name());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && !properties.name().isEmpty()) {
		return new PropertyName(properties.name());
	}

	return PropertyName.USE_DEFAULT;
}
 
开发者ID:aureliano,项目名称:evt-bridge,代码行数:24,代码来源:ElasticSearchAnnotationIntrospector.java

示例4: constructSettableProperty

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
protected SettableBeanProperty constructSettableProperty(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, BeanPropertyDefinition paramBeanPropertyDefinition, Type paramType)
{
  AnnotatedMember localAnnotatedMember = paramBeanPropertyDefinition.getMutator();
  if (paramDeserializationContext.canOverrideAccessModifiers())
    localAnnotatedMember.fixAccess();
  JavaType localJavaType1 = paramBeanDescription.resolveType(paramType);
  BeanProperty.Std localStd = new BeanProperty.Std(paramBeanPropertyDefinition.getName(), localJavaType1, paramBeanPropertyDefinition.getWrapperName(), paramBeanDescription.getClassAnnotations(), localAnnotatedMember, paramBeanPropertyDefinition.isRequired());
  JavaType localJavaType2 = resolveType(paramDeserializationContext, paramBeanDescription, localJavaType1, localAnnotatedMember);
  if (localJavaType2 != localJavaType1)
    localStd.withType(localJavaType2);
  JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationContext, localAnnotatedMember);
  JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationContext, localAnnotatedMember, localJavaType2);
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType3.getTypeHandler();
  Object localObject;
  if ((localAnnotatedMember instanceof AnnotatedMethod))
    localObject = new MethodProperty(paramBeanPropertyDefinition, localJavaType3, localTypeDeserializer, paramBeanDescription.getClassAnnotations(), (AnnotatedMethod)localAnnotatedMember);
  else
    localObject = new FieldProperty(paramBeanPropertyDefinition, localJavaType3, localTypeDeserializer, paramBeanDescription.getClassAnnotations(), (AnnotatedField)localAnnotatedMember);
  if (localJsonDeserializer != null)
    localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer);
  AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramBeanPropertyDefinition.findReferenceType();
  if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference()))
    ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName());
  return localObject;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:26,代码来源:BeanDeserializerFactory.java

示例5: findNameForDeserialization

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
public PropertyName findNameForDeserialization(Annotated paramAnnotated)
{
  String str;
  if ((paramAnnotated instanceof AnnotatedField))
    str = findDeserializationName((AnnotatedField)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedMethod))
    str = findDeserializationName((AnnotatedMethod)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedParameter))
    str = findDeserializationName((AnnotatedParameter)paramAnnotated);
  else
    str = null;
  if (str != null)
  {
    if (str.length() == 0)
      return PropertyName.USE_DEFAULT;
    return new PropertyName(str);
  }
  return null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:AnnotationIntrospector.java

示例6: findNameForSerialization

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
public PropertyName findNameForSerialization(Annotated paramAnnotated)
{
  String str;
  if ((paramAnnotated instanceof AnnotatedField))
    str = findSerializationName((AnnotatedField)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedMethod))
    str = findSerializationName((AnnotatedMethod)paramAnnotated);
  else
    str = null;
  if (str != null)
  {
    if (str.length() == 0)
      return PropertyName.USE_DEFAULT;
    return new PropertyName(str);
  }
  return null;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:18,代码来源:AnnotationIntrospector.java

示例7: verifyClazzIsConfigurable

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
private <T> void verifyClazzIsConfigurable(Class<T> clazz)
{
  final List<BeanPropertyDefinition> beanDefs = jsonMapper.getSerializationConfig()
                                                            .introspect(jsonMapper.constructType(clazz))
                                                            .findProperties();
  for (BeanPropertyDefinition beanDef : beanDefs) {
    final AnnotatedField field = beanDef.getField();
    if (field == null || !field.hasAnnotation(JsonProperty.class)) {
      throw new ProvisionException(
          String.format(
              "JsonConfigurator requires Jackson-annotated Config objects to have field annotations. %s doesn't",
              clazz
          )
      );
    }
  }
}
 
开发者ID:druid-io,项目名称:druid-api,代码行数:18,代码来源:JsonConfigurator.java

示例8: build

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
public static AnnotatedField build(final AnnotatedClass annotatedClass, final Field field,
		final AnnotationMap annotationMap) {
	final Constructor<?> constructor = AnnotatedField.class.getConstructors()[0];
	return ExceptionUtil.wrapCatchedExceptions(new Callable<AnnotatedField>() {
		@Override
		public AnnotatedField call() throws Exception {
			return buildAnnotatedField(annotatedClass, field, annotationMap, constructor);
		}
	}, "Exception while building AnnotatedField");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:11,代码来源:AnnotatedFieldBuilder.java

示例9: buildAnnotatedField

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
private static AnnotatedField buildAnnotatedField(AnnotatedClass annotatedClass, Field field,
		AnnotationMap annotationMap, Constructor<?> constructor)
		throws IllegalAccessException, InstantiationException, InvocationTargetException {
	Class<?> firstParameterType = constructor.getParameterTypes()[0];

	PreconditionUtil.assertTrue(CANNOT_FIND_PROPER_CONSTRUCTOR, firstParameterType == AnnotatedClass.class ||
			TypeResolutionContext.class.equals(firstParameterType));
	return (AnnotatedField) constructor.newInstance(annotatedClass, field, annotationMap);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:10,代码来源:AnnotatedFieldBuilder.java

示例10: getName

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
protected Optional<String> getName(Field field) {
	ObjectMapper objectMapper = context.getObjectMapper();
	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();

	if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
		AnnotationMap annotationMap = buildAnnotationMap(field.getDeclaredAnnotations());

		AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(field.getDeclaringClass(), serializationConfig);
		AnnotatedField annotatedField = AnnotatedFieldBuilder.build(annotatedClass, field, annotationMap);
		return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForField(serializationConfig, annotatedField, field.getName()));
	}
	return Optional.empty();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:14,代码来源:JacksonResourceFieldInformationProvider.java

示例11: nameForField

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
@Override
public String nameForField(MapperConfig<?> config, AnnotatedField field, String defaultName) {
  if (field.getDeclaringClass() == this.effectiveType) {
    return fieldToJsonMapping
        .getOrDefault(defaultName, super.nameForField(config, field, defaultName));
  } else {
    return super.nameForField(config, field, defaultName);
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:10,代码来源:EsPropertyNamingStrategy.java

示例12: getName

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
public String getName(Field field) {

        String name = field.getName();
        if (field.isAnnotationPresent(JsonProperty.class) &&
            !"".equals(field.getAnnotation(JsonProperty.class).value())) {
            name = field.getAnnotation(JsonProperty.class).value();
        } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
            AnnotationMap annotationMap = buildAnnotationMap(field.getDeclaredAnnotations());

            AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(field.getDeclaringClass(), serializationConfig);
            AnnotatedField annotatedField = AnnotatedFieldBuilder.build(annotatedClass, field, annotationMap);
            name = serializationConfig.getPropertyNamingStrategy().nameForField(serializationConfig, annotatedField, name);
        }
        return name;
    }
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:16,代码来源:ResourceFieldNameTransformer.java

示例13: build

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
public static AnnotatedField build(AnnotatedClass annotatedClass, Field field, AnnotationMap annotationMap) {
    for(Constructor<?> constructor : AnnotatedField.class.getConstructors()) {
        try {
            return buildAnnotatedField(annotatedClass, field, annotationMap, constructor);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
            throw new InternalException("Exception while building " + AnnotatedField.class.getCanonicalName(), e);
        }
    }
    throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:11,代码来源:AnnotatedFieldBuilder.java

示例14: buildAnnotatedField

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
private static AnnotatedField buildAnnotatedField(AnnotatedClass annotatedClass, Field field,
                                                  AnnotationMap annotationMap, Constructor<?> constructor)
        throws IllegalAccessException, InstantiationException, InvocationTargetException {
    Class<?> firstParameterType = constructor.getParameterTypes()[0];
    if (firstParameterType == AnnotatedClass.class ||
            "TypeResolutionContext".equals(firstParameterType.getSimpleName())) {
        return (AnnotatedField) constructor.newInstance(annotatedClass, field, annotationMap);
    } else {
        throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
    }
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:12,代码来源:AnnotatedFieldBuilder.java

示例15: createContextual

import com.fasterxml.jackson.databind.introspect.AnnotatedField; //导入依赖的package包/类
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
	if (property != null) {
		Annotated annotated = property.getMember();
		if (annotated instanceof AnnotatedField || annotated instanceof AnnotatedMethod) {
			IndexableProperty indexableProperty = annotated.getAnnotation(IndexableProperty.class);
			if (indexableProperty != null && !indexableProperty.format().isEmpty()) {
				formatString = indexableProperty.format();
			}
		}
	}
	
	return this;
}
 
开发者ID:aureliano,项目名称:evt-bridge,代码行数:15,代码来源:DateSerializer.java


注:本文中的com.fasterxml.jackson.databind.introspect.AnnotatedField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。