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


Java AnnotationMap类代码示例

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


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

示例1: getName

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
protected Optional<String> getName(Method method) {
	ObjectMapper objectMapper = context.getObjectMapper();
	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
	if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
		String name = ClassUtils.getGetterFieldName(method);
		Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
		AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

		int paramsLength = method.getParameterAnnotations().length;
		AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
		for (int i = 0; i < paramsLength; i++) {
			AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
			paramAnnotations[i] = parameterAnnotationMap;
		}

		AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
		AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
		return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
	}
	return Optional.empty();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:22,代码来源:JacksonResourceFieldInformationProvider.java

示例2: getName

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
/**
 * Extract name to be used by Katharsis from getter's name. It uses
 * {@link ResourceFieldNameTransformer#getMethodName(Method)}, {@link JsonProperty} annotation and
 * {@link PropertyNamingStrategy}.
 *
 * @param method method to extract name
 * @return method name
 */
public String getName(Method method) {
    String name = getMethodName(method);

    if (method.isAnnotationPresent(JsonProperty.class) &&
        !"".equals(method.getAnnotation(JsonProperty.class).value())) {
        name = method.getAnnotation(JsonProperty.class).value();
    } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
        Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
        AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

        int paramsLength = method.getParameterAnnotations().length;
        AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
        for (int i = 0; i < paramsLength; i++) {
            AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
            paramAnnotations[i] = parameterAnnotationMap;
        }

        AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
        AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
        name = serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name);
    }
    return name;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:32,代码来源:ResourceFieldNameTransformer.java

示例3: ConstructorParameterModelProperty

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
/**
 * Creates a ConstructorParameterModelProperty which provides a ModelProperty
 * for constructor parameters.
 *
 * @param resolvedParameterType the parameter type
 * @param alternateTypeProvider provider for resolving alternatives for the given param type
 * @param annotationMap map of annotations for the given parameter. it must contain a @JsonProperty annotation.
 */
public ConstructorParameterModelProperty(
        ResolvedType resolvedParameterType,
        AlternateTypeProvider alternateTypeProvider,
        AnnotationMap annotationMap) {

    this.resolvedParameterType = alternateTypeProvider.alternateFor(resolvedParameterType);

    if (this.resolvedParameterType == null) {
        this.resolvedParameterType = resolvedParameterType;
    }

    setJsonProperty(annotationMap.get(JsonProperty.class));
    setTypeName();
    setAllowableValues();
    setQualifiedTypeName();
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:25,代码来源:ConstructorParameterModelProperty.java

示例4: build

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的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

示例5: buildAnnotatedField

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的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

示例6: build

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
public static AnnotatedMethod build(final AnnotatedClass annotatedClass, final Method method,
		final AnnotationMap annotationMap,
		final AnnotationMap[] paramAnnotations) {

	final Constructor<?> constructor = AnnotatedMethod.class.getConstructors()[0];

	return ExceptionUtil.wrapCatchedExceptions(new Callable<AnnotatedMethod>() {
		@Override
		public AnnotatedMethod call() throws Exception {
			return buildAnnotatedField(annotatedClass, method, annotationMap, paramAnnotations, constructor);
		}
	}, "Exception while building AnnotatedMethod");
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:14,代码来源:AnnotatedMethodBuilder.java

示例7: buildAnnotatedField

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
private static AnnotatedMethod buildAnnotatedField(AnnotatedClass annotatedClass, Method method,
		AnnotationMap annotationMap, AnnotationMap[] paramAnnotations,
		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 (AnnotatedMethod) constructor.newInstance(annotatedClass, method, annotationMap, paramAnnotations);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:11,代码来源:AnnotatedMethodBuilder.java

示例8: buildAnnotationMap

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
private static AnnotationMap buildAnnotationMap(Annotation[] declaredAnnotations) {
	AnnotationMap annotationMap = new AnnotationMap();
	for (Annotation annotation : declaredAnnotations) {
		annotationMap.add(annotation);
	}
	return annotationMap;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:8,代码来源:JacksonResourceFieldInformationProvider.java

示例9: buildAnnotationMap

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
private static AnnotationMap buildAnnotationMap(Annotation[] declaredAnnotations) {
    AnnotationMap annotationMap = new AnnotationMap();
    for (Annotation annotation : declaredAnnotations) {
        annotationMap.add(annotation);
    }
    return annotationMap;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:8,代码来源:ResourceFieldNameTransformer.java

示例10: build

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的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

示例11: buildAnnotatedField

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的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

示例12: build

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

示例13: buildAnnotatedField

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

示例14: getModelProperties

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
/**
 * Creates a collection of ConstructorParameterModelProperty objects from the arguments of the given ResolvedConstructor.
 * Only args annotated with @JsonProperty are included. Scala Case Classes are a special case and do not require the annotation.
 *
 * @param resolvedConstructor the constructor to get
 * @param alternateTypeProvider for resolving alternative types for the found arguments
 * @return the collection of ConstructorParameterModelProperty objects
 */
public static ImmutableList<ConstructorParameterModelProperty> getModelProperties(ResolvedConstructor resolvedConstructor, AlternateTypeProvider alternateTypeProvider){
    Builder<ConstructorParameterModelProperty> listBuilder = new Builder<>();
    if(resolvedConstructor.getRawMember().getAnnotation(JsonCreator.class) != null || scala.Product.class.isAssignableFrom(resolvedConstructor.getDeclaringType().getErasedType())){
        //constructor for normal classes must be annotated with @JsonCreator. Scala Case Classes are a special case
        for(int i=0;i<resolvedConstructor.getArgumentCount();i++){
            AnnotationMap annotationMap = annotationMap(resolvedConstructor.getRawMember().getParameterAnnotations()[i]);
            ResolvedType parameterType = resolvedConstructor.getArgumentType(i);
            if(annotationMap.get(JsonProperty.class) != null){
                listBuilder.add(new ConstructorParameterModelProperty(parameterType, alternateTypeProvider, annotationMap));
            }
        }
    }
    return listBuilder.build();
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:23,代码来源:ConstructorParameterModelProperty.java

示例15: getTSTypeForClass

import com.fasterxml.jackson.databind.introspect.AnnotationMap; //导入依赖的package包/类
private AbstractType getTSTypeForClass(AnnotatedMember member) {

		TypeBindings bindings = new TypeBindings(TypeFactory.defaultInstance(), member.getDeclaringClass());
		BeanProperty prop = new BeanProperty.Std(member.getName(), member.getType(bindings), NO_NAME,
				new AnnotationMap(), member, false);

		try {
			return getTSTypeForProperty(prop);
		} catch (JsonMappingException e) {
			throw new RuntimeException(e);
		}
	}
 
开发者ID:raphaeljolivet,项目名称:java2typescript,代码行数:13,代码来源:TSJsonObjectFormatVisitor.java


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