Package com.fasterxml.jackson.databind.ser

Examples of com.fasterxml.jackson.databind.ser.Serializers


  public void setModules() {
    NumberSerializer serializer1 = new NumberSerializer();
    SimpleModule module = new SimpleModule();
    module.addSerializer(Integer.class, serializer1);
    ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(Arrays.asList(new Module[]{module})).build();
    Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
    assertTrue(serializers.findSerializer(null, SimpleType.construct(Integer.class), null) == serializer1);
  }
View Full Code Here


  public void serializerByType() {
    JsonSerializer<Number> serializer = new NumberSerializer();
    ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
        .serializerByType(Boolean.class, serializer).build();
    assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
    Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
    assertTrue(serializers.findSerializer(null, SimpleType.construct(Boolean.class), null) == serializer);
  }
View Full Code Here

    builder.configure(objectMapper);

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

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

    Deserializers deserializers = getDeserializerFactoryConfig(objectMapper).deserializers().iterator().next();
    assertTrue(deserializers.findBeanDeserializer(SimpleType.construct(Date.class), null, null) == deserializer);

    assertTrue(annotationIntrospector == objectMapper.getSerializationConfig().getAnnotationIntrospector());
View Full Code Here

    this.factory.setModules(Arrays.asList(new Module[] {module}));
    this.factory.afterPropertiesSet();
    ObjectMapper objectMapper = this.factory.getObject();

    Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
    assertTrue(serializers.findSerializer(null, SimpleType.construct(Integer.class), null) == serializer1);
  }
View Full Code Here

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

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

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

    assertTrue(objectMapper.getSerializationConfig().isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS));
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.ser.Serializers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.