Java Code Examples for com.fasterxml.jackson.databind.cfg.MapperConfig#getTypeFactory()

The following examples show how to use com.fasterxml.jackson.databind.cfg.MapperConfig#getTypeFactory() . 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: StdTypeResolverBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method that will either return configured custom
 * type id resolver, or construct a standard resolver
 * given configuration.
 */
protected TypeIdResolver idResolver(MapperConfig<?> config,
        JavaType baseType, Collection<NamedType> subtypes, boolean forSer, boolean forDeser)
{
    // Custom id resolver?
    if (_customIdResolver != null) { return _customIdResolver; }
    if (_idType == null) throw new IllegalStateException("Cannot build, 'init()' not yet called");
    switch (_idType) {
    case CLASS:
        return new ClassNameIdResolver(baseType, config.getTypeFactory());
    case MINIMAL_CLASS:
        return new MinimalClassNameIdResolver(baseType, config.getTypeFactory());
    case NAME:
        return TypeNameIdResolver.construct(config, baseType, subtypes, forSer, forDeser);
    case NONE: // hmmh. should never get this far with 'none'
        return null;
    case CUSTOM: // need custom resolver...
    }
    throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: "+_idType);
}
 
Example 2
Source File: TypeNameIdResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected TypeNameIdResolver(MapperConfig<?> config, JavaType baseType,
        Map<String, String> typeToId, Map<String, JavaType> idToType)
{
    super(baseType, config.getTypeFactory());
    _config = config;
    _typeToId = typeToId;
    _idToType = idToType;
}
 
Example 3
Source File: JaxbAnnotationIntrospector.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
protected Converter<Object,Object> _converter(MapperConfig<?> config,
        XmlAdapter<?,?> adapter, boolean forSerialization)
{
    TypeFactory tf = config.getTypeFactory();
    JavaType adapterType = tf.constructType(adapter.getClass());
    JavaType[] pt = tf.findTypeParameters(adapterType, XmlAdapter.class);
    // Order of type parameters for Converter is reverse between serializer, deserializer,
    // whereas JAXB just uses single ordering
    if (forSerialization) {
        return new AdapterConverter(adapter, pt[1], pt[0], forSerialization);
    }
    return new AdapterConverter(adapter, pt[0], pt[1], forSerialization);
}
 
Example 4
Source File: NsTypeResolverBuilder.java    From components with Apache License 2.0 5 votes vote down vote up
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType,
                                    PolymorphicTypeValidator subtypeValidator, Collection<NamedType> subtypes,
                                    boolean forSer, boolean forDeser) {
    if (_idType == null) {
        throw new IllegalStateException("Can not build, 'init()' not yet called");
    }

    return new NsTypeIdResolver(baseType, config.getTypeFactory(), basicMetaData);
}
 
Example 5
Source File: BeanBuilder.java    From jackson-modules-base with Apache License 2.0 4 votes vote down vote up
public static BeanBuilder construct(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
{
    return new BeanBuilder(type, ac, config.getTypeFactory());
}
 
Example 6
Source File: ClassAliasTypeResolverBuilder.java    From simple-spring-memcached with MIT License 4 votes vote down vote up
@Override
protected TypeIdResolver idResolver(final MapperConfig<?> config, final JavaType baseType, final Collection<NamedType> subtypes,
        final boolean forSer, final boolean forDeser) {
    return new ClassAliasIdResolver(baseType, config.getTypeFactory(), idToClass, classToId);
}
 
Example 7
Source File: MarshallerService.java    From dawnsci with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected TypeIdResolver idResolver(MapperConfig<?> config,
JavaType baseType, Collection<NamedType> subtypes,
boolean forSer, boolean forDeser) {
	return new RegisteredClassIdResolver(baseType, config.getTypeFactory(), registry);
}