com.fasterxml.jackson.databind.cfg.SerializerFactoryConfig Java Examples

The following examples show how to use com.fasterxml.jackson.databind.cfg.SerializerFactoryConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanSerializerFactory.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Method used by module registration functionality, to attach additional
 * serializer providers into this serializer factory. This is typically
 * handled by constructing a new instance with additional serializers,
 * to ensure thread-safe access.
 */
@Override
public SerializerFactory withConfig(SerializerFactoryConfig config)
{
    if (_factoryConfig == config) {
        return this;
    }
    /* 22-Nov-2010, tatu: Handling of subtypes is tricky if we do immutable-with-copy-ctor;
     *    and we pretty much have to here either choose between losing subtype instance
     *    when registering additional serializers, or losing serializers.
     *    Instead, let's actually just throw an error if this method is called when subtype
     *    has not properly overridden this method; this to indicate problem as soon as possible.
     */
    if (getClass() != BeanSerializerFactory.class) {
        throw new IllegalStateException("Subtype of BeanSerializerFactory ("+getClass().getName()
                +") has not properly overridden method 'withAdditionalSerializers': can not instantiate subtype with "
                +"additional serializer definitions");
    }
    return new BeanSerializerFactory(config);
}
 
Example #2
Source File: BeanSerializerFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method used by module registration functionality, to attach additional
 * serializer providers into this serializer factory. This is typically
 * handled by constructing a new instance with additional serializers,
 * to ensure thread-safe access.
 */
@Override
public SerializerFactory withConfig(SerializerFactoryConfig config)
{
    if (_factoryConfig == config) {
        return this;
    }
    /* 22-Nov-2010, tatu: Handling of subtypes is tricky if we do immutable-with-copy-ctor;
     *    and we pretty much have to here either choose between losing subtype instance
     *    when registering additional serializers, or losing serializers.
     *    Instead, let's actually just throw an error if this method is called when subtype
     *    has not properly overridden this method; this to indicate problem as soon as possible.
     */
    if (getClass() != BeanSerializerFactory.class) {
        throw new IllegalStateException("Subtype of BeanSerializerFactory ("+getClass().getName()
                +") has not properly overridden method 'withAdditionalSerializers': cannot instantiate subtype with "
                +"additional serializer definitions");
    }
    return new BeanSerializerFactory(config);
}
 
Example #3
Source File: JsonUtilWithDefaultErrorContractDTOSupport.java    From backstopper with Apache License 2.0 5 votes vote down vote up
protected ErrorContractSerializationFactory(SerializerFactoryConfig config,
                                            boolean excludeEmptyMetadataFromJson,
                                            boolean serializeErrorCodeFieldAsIntegerIfPossible) {
    super(config);
    this.excludeEmptyMetadataFromJson = excludeEmptyMetadataFromJson;
    this.serializeErrorCodeFieldAsIntegerIfPossible = serializeErrorCodeFieldAsIntegerIfPossible;
}
 
Example #4
Source File: CustomBeanSerializerFactory.java    From caravan with Apache License 2.0 5 votes vote down vote up
@Override
public SerializerFactory withConfig(SerializerFactoryConfig config)
{
  if (_factoryConfig == config) {
    return this;
  }
  if (getClass() != CustomBeanSerializerFactory.class) {
    throw new IllegalStateException("Subtype of BeanSerializerFactory ("+getClass().getName()
        +") has not properly overridden method 'withAdditionalSerializers': can not instantiate subtype with "
        +"additional serializer definitions");
  }
  return new CustomBeanSerializerFactory(config);
}
 
Example #5
Source File: FilterObjectMapperBuilderTest.java    From jfilter with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigureSerializersFalse() {
    SerializerFactoryConfig serializerFactoryConfig = getFactoryConfig(filterObjectMapperFalse);

    boolean jdk8SerializerExist = serializerExist(serializerFactoryConfig.serializers(), Jdk8Serializers.class);
    assertFalse(jdk8SerializerExist);

    boolean simpleSerializerExist = serializerExist(serializerFactoryConfig.serializers(), SimpleSerializers.class);
    assertFalse(simpleSerializerExist);
}
 
Example #6
Source File: FilterObjectMapperBuilderTest.java    From jfilter with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigureSerializersTrue() {
    SerializerFactoryConfig serializerFactoryConfig = getFactoryConfig(filterObjectMapperTrue);

    boolean jdk8SerializerExist = serializerExist(serializerFactoryConfig.serializers(), Jdk8Serializers.class);
    assertTrue(jdk8SerializerExist);

    boolean simpleSerializerExist = serializerExist(serializerFactoryConfig.serializers(), SimpleSerializers.class);
    assertTrue(simpleSerializerExist);
}
 
Example #7
Source File: ObjectMapperFactoryV2.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
@Override
public StrictSerializerFactory withConfig(SerializerFactoryConfig config)
{
    if (_factoryConfig == config) {
        return this;
    }
    return new StrictSerializerFactory(config);
}
 
Example #8
Source File: BeanSerializerFactory.java    From bistoury with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor for creating instances with specified configuration.
 */
protected BeanSerializerFactory(SerializerFactoryConfig config)
{
    super(config);
}
 
Example #9
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #10
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #11
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #12
Source File: MappingJackson2XmlViewTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #13
Source File: MappingJackson2JsonViewTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #14
Source File: ObjectMapperFactoryV2.java    From aws-athena-query-federation with Apache License 2.0 4 votes vote down vote up
private StrictSerializerFactory(SerializerFactoryConfig config)
{
    super(config);
}
 
Example #15
Source File: CustomBeanSerializerFactory.java    From caravan with Apache License 2.0 4 votes vote down vote up
public CustomBeanSerializerFactory(SerializerFactoryConfig config) {
  super(config);
}
 
Example #16
Source File: BeanSerializerFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor for creating instances with specified configuration.
 */
protected BeanSerializerFactory(SerializerFactoryConfig config)
{
    super(config);
}
 
Example #17
Source File: EntityCustomSerializationFactory.java    From bboss-elasticsearch with Apache License 2.0 4 votes vote down vote up
protected EntityCustomSerializationFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #18
Source File: MappingJackson2JsonViewTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #19
Source File: MappingJackson2XmlViewTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #20
Source File: FilterObjectMapperBuilderTest.java    From jfilter with Apache License 2.0 4 votes vote down vote up
private SerializerFactoryConfig getFactoryConfig(ObjectMapper objectMapper) {
    BasicSerializerFactory serializationConfig = (BasicSerializerFactory) objectMapper.getSerializerFactory();
    return serializationConfig.getFactoryConfig();
}
 
Example #21
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #22
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #23
Source File: MappingJackson2XmlViewTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #24
Source File: MappingJackson2JsonViewTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected DelegatingSerializerFactory(SerializerFactoryConfig config) {
	super(config);
}
 
Example #25
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {
	return ((BasicSerializerFactory) objectMapper.getSerializerFactory()).getFactoryConfig();
}
 
Example #26
Source File: BasicSerializerFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * We will provide default constructor to allow sub-classing,
 * but make it protected so that no non-singleton instances of
 * the class will be instantiated.
 */
protected BasicSerializerFactory(SerializerFactoryConfig config) {
    _factoryConfig = (config == null) ? new SerializerFactoryConfig() : config;
}
 
Example #27
Source File: BasicSerializerFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method for getting current {@link SerializerFactoryConfig}.
  *<p>
 * Note that since instances are immutable, you can NOT change settings
 * by accessing an instance and calling methods: this will simply create
 * new instance of config object.
 */
public SerializerFactoryConfig getFactoryConfig() {
    return _factoryConfig;
}
 
Example #28
Source File: BasicSerializerFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method used for creating a new instance of this factory, but with different
 * configuration. Reason for specifying factory method (instead of plain constructor)
 * is to allow proper sub-classing of factories.
 *<p>
 * Note that custom sub-classes generally <b>must override</b> implementation
 * of this method, as it usually requires instantiating a new instance of
 * factory type. Check out javadocs for
 * {@link com.fasterxml.jackson.databind.ser.BeanSerializerFactory} for more details.
 */
public abstract SerializerFactory withConfig(SerializerFactoryConfig config);