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


Java NopAnnotationIntrospector类代码示例

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


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

示例1: setupModule

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
@Override
public void setupModule(SetupContext context) {

	context.insertAnnotationIntrospector(new NopAnnotationIntrospector() {

		private static final long serialVersionUID = 479313244908256455L;

		@Override
		public boolean hasIgnoreMarker(AnnotatedMember m) {

			if (!(m instanceof AnnotatedMethod)) {
				return super.hasIgnoreMarker(m);
			}

			AnnotatedMethod method = (AnnotatedMethod) m;

			return method.getName().startsWith("lambda$") ? true : super.hasIgnoreMarker(m);
		}
	});
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:21,代码来源:IssueTrackerConfiguration.java

示例2: getAnnotationIntrospector

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
/**
 * Method for getting {@link AnnotationIntrospector} configured
 * to introspect annotation values used for configuration.
 */
@Override
public AnnotationIntrospector getAnnotationIntrospector()
{
    /* 29-Jul-2009, tatu: it's now possible to disable use of
     *   annotations; can be done using "no-op" introspector
     */
    if (isEnabled(MapperFeature.USE_ANNOTATIONS)) {
        return super.getAnnotationIntrospector();
    }
    return NopAnnotationIntrospector.instance;
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:16,代码来源:DeserializationConfig.java

示例3: completeSetup

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
@Test
public void completeSetup() {
	NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
	ObjectMapper objectMapper = new ObjectMapper();

	this.factory.setObjectMapper(objectMapper);
	assertTrue(this.factory.isSingleton());
	assertEquals(ObjectMapper.class, this.factory.getObjectType());

	Map<Class<?>, JsonDeserializer<?>> deserializers = new HashMap<Class<?>, JsonDeserializer<?>>();
	deserializers.put(Date.class, new DateDeserializer());

	JsonSerializer<Class<?>> serializer1 = new ClassSerializer();
	JsonSerializer<Number> serializer2 = new NumberSerializer(Integer.class);

	// Disable well-known modules detection
	this.factory.setModules(new ArrayList<>());
	this.factory.setSerializers(serializer1);
	this.factory.setSerializersByType(Collections.singletonMap(Boolean.class, serializer2));
	this.factory.setDeserializersByType(deserializers);
	this.factory.setAnnotationIntrospector(annotationIntrospector);

	this.factory.setFeaturesToEnable(SerializationFeature.FAIL_ON_EMPTY_BEANS,
			DeserializationFeature.UNWRAP_ROOT_VALUE,
			JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER,
			JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);

	this.factory.setFeaturesToDisable(MapperFeature.AUTO_DETECT_GETTERS,
			MapperFeature.AUTO_DETECT_FIELDS,
			JsonParser.Feature.AUTO_CLOSE_SOURCE,
			JsonGenerator.Feature.QUOTE_FIELD_NAMES);

	assertFalse(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertFalse(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	this.factory.setSerializationInclusion(Include.NON_NULL);
	this.factory.afterPropertiesSet();

	assertSame(objectMapper, this.factory.getObject());
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer1, serializers.findSerializer(null, SimpleType.construct(Class.class), null));
	assertSame(serializer2, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
	assertNull(serializers.findSerializer(null, SimpleType.construct(Number.class), null));

	assertSame(annotationIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector());
	assertSame(annotationIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector());

	assertTrue(objectMapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS));
	assertTrue(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
	assertTrue(objectMapper.getFactory().isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
	assertTrue(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));

	assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
	assertFalse(objectMapper.getFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE));
	assertFalse(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES));
	assertSame(Include.NON_NULL, objectMapper.getSerializationConfig().getSerializationInclusion());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:64,代码来源:Jackson2ObjectMapperFactoryBeanTests.java

示例4: getAnnotationIntrospector

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
public final AnnotationIntrospector getAnnotationIntrospector()
{
  if (isEnabled(MapperFeature.USE_ANNOTATIONS))
    return super.getAnnotationIntrospector();
  return NopAnnotationIntrospector.instance;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:7,代码来源:DeserializationConfig.java

示例5: nopInstance

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
public static AnnotationIntrospector nopInstance()
{
  return NopAnnotationIntrospector.instance;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:AnnotationIntrospector.java

示例6: testCompleteSetup

import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
@Test
public void testCompleteSetup() {
	NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
	ObjectMapper objectMapper = new ObjectMapper();

	assertTrue(this.factory.isSingleton());
	assertEquals(ObjectMapper.class, this.factory.getObjectType());

	Map<Class<?>, JsonDeserializer<?>> deserializers = new HashMap<Class<?>, JsonDeserializer<?>>();
	deserializers.put(Date.class, new DateDeserializer());

	this.factory.setObjectMapper(objectMapper);
	this.factory.setSerializers(new ClassSerializer());
	this.factory.setDeserializersByType(deserializers);
	this.factory.setAnnotationIntrospector(annotationIntrospector);

	this.factory.setFeaturesToEnable(
			SerializationFeature.FAIL_ON_EMPTY_BEANS,
			DeserializationFeature.UNWRAP_ROOT_VALUE,
			JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER,
			JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);

	this.factory.setFeaturesToDisable(
			MapperFeature.AUTO_DETECT_GETTERS,
			MapperFeature.AUTO_DETECT_FIELDS,
			JsonParser.Feature.AUTO_CLOSE_SOURCE,
			JsonGenerator.Feature.QUOTE_FIELD_NAMES);

	assertFalse(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertFalse(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	this.factory.afterPropertiesSet();

	assertTrue(objectMapper == this.factory.getObject());

	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());

	assertTrue(annotationIntrospector == objectMapper.getSerializationConfig().getAnnotationIntrospector());
	assertTrue(annotationIntrospector == objectMapper.getDeserializationConfig().getAnnotationIntrospector());

	assertTrue(objectMapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS));
	assertTrue(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
	assertTrue(objectMapper.getJsonFactory().isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
	assertTrue(objectMapper.getJsonFactory().isEnabled(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS));

	assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
	assertFalse(objectMapper.getJsonFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE));
	assertFalse(objectMapper.getJsonFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:52,代码来源:Jackson2ObjectMapperFactoryBeanTests.java


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