本文整理汇总了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);
}
});
}
示例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;
}
示例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());
}
示例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;
}
示例5: nopInstance
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; //导入依赖的package包/类
public static AnnotationIntrospector nopInstance()
{
return NopAnnotationIntrospector.instance;
}
示例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));
}