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


Java Annotated类代码示例

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


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

示例1: getObjectMapper

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Bean(name = "objectMapper")
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();

    mapper.registerModule(new GuavaModule());
    mapper.registerModule(new Jdk8Module());
    mapper.registerModule(new JodaModule());
    mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
        // borrowed from: http://jackson-users.ning.com/forum/topics/how-to-not-include-type-info-during-serialization-with
        @Override
        protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ann, JavaType baseType) {

            // Don't serialize JsonTypeInfo Property includes
            if (ann.hasAnnotation(JsonTypeInfo.class)
                    && ann.getAnnotation(JsonTypeInfo.class).include() == JsonTypeInfo.As.PROPERTY
                    && SerializationConfig.class.isAssignableFrom(config.getClass())) {
                return null;

            }

            return super._findTypeResolver(config, ann, baseType);
        }
    });

    return mapper;
}
 
开发者ID:bpatters,项目名称:eservice,代码行数:27,代码来源:CommonBeans.java

示例2: findSerializer

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findSerializer(Annotated annotatedMethod) {
	IdFormat annotation = annotatedMethod.getAnnotation(IdFormat.class);
	if (annotatedMethod.getRawType() == UUID.class) {
		if (annotation != null) {
			switch (annotation.value()) {
				case RAW:
					return UUIDSerializer.class;
				case URL62:
					return FriendlyIdSerializer.class;
			}
		}
		return FriendlyIdSerializer.class;
	} else {
		return null;
	}
}
 
开发者ID:Devskiller,项目名称:friendly-id,代码行数:18,代码来源:FriendlyIdAnnotationIntrospector.java

示例3: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findDeserializer(Annotated annotatedMethod) {
	IdFormat annotation = annotatedMethod.getAnnotation(IdFormat.class);
	if (rawDeserializationType(annotatedMethod) == UUID.class) {
		if (annotation != null) {
			switch (annotation.value()) {
				case RAW:
					return UUIDDeserializer.class;
				case URL62:
					return FriendlyIdDeserializer.class;
			}
		}
		return FriendlyIdDeserializer.class;
	} else {
		return null;
	}
}
 
开发者ID:Devskiller,项目名称:friendly-id,代码行数:18,代码来源:FriendlyIdAnnotationIntrospector.java

示例4: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findDeserializer(Annotated a) {
	// System.err.println("Annotated:" + a.getClass().getName() + " " + a);

	if (a instanceof AnnotatedClass) {
		Class<?> clazz = ((AnnotatedClass) a).getAnnotated();
		// System.err.println("clazz:" + clazz.getName() + " " + a.getName());

		if (clazz.isEnum()) {
			if (Onum.class.isAssignableFrom(clazz)) {
				// System.err.println("OnumJsonSerializerIntrospector findDeserializer:" + clazz.getName() + " a:" + a);
				return new OnumJsonDeserializer(clazz);
			}
		}
	}

	Object deserializer = super.findDeserializer(a);
	return deserializer;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:20,代码来源:DisablingJsonSerializerIntrospector.java

示例5: getObjectMapper

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
ObjectMapper getObjectMapper() {
        ObjectMapper objectMapper = ObjectMapperBuilder.buildNewObjectMapper();
//        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        SimpleModule module = new SimpleModule();
        module.addSerializer(BigDecimal.class, new ToStringSerializer());
        module.addSerializer(Long.class, new ToStringSerializer());
        objectMapper.registerModule(module);

        //Disable JsonIdentityInfo
        JacksonAnnotationIntrospector ignoreJsonTypeInfoIntrospector = new JacksonAnnotationIntrospector() {
            @Override
            public ObjectIdInfo findObjectIdInfo(Annotated ann) {
                return null;
            }
        };
        objectMapper.setAnnotationIntrospector(ignoreJsonTypeInfoIntrospector);

        return objectMapper;
    }
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:20,代码来源:HttpServer.java

示例6: findDeserializationConverter

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findDeserializationConverter(Annotated a) {
    JtToMap ann = a.getAnnotation(JtToMap.class);
    if (ann == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new DeserializationConverterImpl(ann, new Ctx(a, javaType));
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:18,代码来源:JtModule.java

示例7: findDeserializationConverter

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findDeserializationConverter(Annotated a) {
    Class<? extends PropertyInterceptor>[] interceptors = getInterceptors(a);
    if (interceptors == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new KvInterceptorsDeserializationConverter(interceptors, new KvPropertyContextImpl(a, javaType));
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:18,代码来源:KvSupportModule.java

示例8: setup

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Before
public void setup() {
	typeResolver = mock(TypeResolver.class);
	configuration = Configuration.build();
	
	instantiator = mock(HandlerInstantiator.class);
	
	doReturn(new ResourceDeserializer(Object.class, typeResolver, configuration))
		.when(instantiator).deserializerInstance(any(DeserializationConfig.class),
				any(Annotated.class), eq(ResourceDeserializer.class));
			
	mapper = new ObjectMapper();
	mapper.setHandlerInstantiator(instantiator);
	mapper.registerModule(new Jackson2HalModule());
	mapper.registerModule(new TestModule());
	mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:18,代码来源:ResourceDeserializerTest.java

示例9: findNameForSerialization

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

示例10: findSerializationInclusion

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) {
	IndexableProperty property = a.getAnnotation(IndexableProperty.class);
	if (property != null && property.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(property.jsonInclude().toString());
	}

	IndexableComponent component = a.getAnnotation(IndexableComponent.class);
	if (component != null && component.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(component.jsonInclude().toString());
	}

	IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
	if (properties != null && properties.jsonInclude() != com.github.aureliano.evtbridge.output.elasticsearch.enumeration.JsonInclude.DEFAULT) {
		return JsonInclude.Include.valueOf(properties.jsonInclude().toString());
	}
	return defValue;
}
 
开发者ID:aureliano,项目名称:evt-bridge,代码行数:19,代码来源:ElasticSearchAnnotationIntrospector.java

示例11: findNameForDeserialization

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

示例12: createContextual

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
                                            BeanProperty property) throws JsonMappingException {
    if (property != null) {
        JsonFormat.Value format = ctxt.getAnnotationIntrospector().findFormat((Annotated) property.getMember());
        if (format != null) {
            if (format.hasPattern()) {
                final String pattern = format.getPattern();
                final Locale locale = format.hasLocale() ? format.getLocale() : ctxt.getLocale();
                DateTimeFormatter df;
                if (locale == null) {
                    df = DateTimeFormatter.ofPattern(pattern);
                } else {
                    df = DateTimeFormatter.ofPattern(pattern, locale);
                }
                return withDateFormat(df);
            }
            // any use for TimeZone?
        }
    }
    return this;
}
 
开发者ID:bootique,项目名称:bootique,代码行数:23,代码来源:JSR310DateTimeDeserializerBase.java

示例13: findSerializer

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findSerializer( Annotated annotated ) {

    if( ! annotated.hasAnnotation(Column.class) || ! isStringType(annotated) ) {
        return super.findSerializer( annotated );
    }

    Class classType = annotated.getRawType();

    if( Types.isNotString(classType) ) {
        if( Types.isBoolean(classType) ) {
            return ColumnBooleanSerializer.class;
        } else if( ! Types.isPrimitive(classType) ) {
            return ColumnBeanSerializer.class;
        }
    }

    return super.findSerializer( annotated );

}
 
开发者ID:NyBatis,项目名称:NyBatisCore,代码行数:21,代码来源:ColumnAnnotationInspector.java

示例14: findDeserializer

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
@Override
public Object findDeserializer( Annotated annotated ) {

    if( ! annotated.hasAnnotation(Column.class) || ! isStringType(annotated) ) {
        return super.findDeserializer( annotated );
    }

    Class classType;
    try {
        classType = ( (AnnotatedMethod) annotated ).getRawParameterType( 0 );
    } catch( Exception e ) {
        classType = annotated.getRawType();
    }

    if( Types.isNotString(classType) ) {
        if( Types.isBoolean(classType) ) {
            return ColumnBooleanDeserializer.class;
        } else if( ! Types.isPrimitive(classType) ) {
            return ColumnBeanDeserializer.class;
        }
    }

    return super.findDeserializer( annotated );

}
 
开发者ID:NyBatis,项目名称:NyBatisCore,代码行数:26,代码来源:ColumnAnnotationInspector.java

示例15: getPropertyName

import com.fasterxml.jackson.databind.introspect.Annotated; //导入依赖的package包/类
private PropertyName getPropertyName( Annotated annotated ) {

        Column column = annotated.getAnnotation( Column.class );
        if ( column != null && StringUtil.isNotEmpty(annotated.getName()) ) {
            String name = column.name();
            name = StringUtil.toUncamel( name );
            name = StringUtil.toCamel( name );
            return new PropertyName( name );
        }

        JsonProperty jsonProperty = annotated.getAnnotation( JsonProperty.class );
        if( jsonProperty != null ) {
            if( StringUtil.isNotEmpty(jsonProperty.value()) ) {
                return new PropertyName( jsonProperty.value() );
            } else {
                return PropertyName.USE_DEFAULT;
            }
        }

        return null;

    }
 
开发者ID:NyBatis,项目名称:NyBatisCore,代码行数:23,代码来源:ColumnAnnotationInspector.java


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