Examples of PluginMap


Examples of com.addthis.codec.plugins.PluginMap

            return;
        }

        // find any parent class (or itself) with a Pluggable annotation
        Class<?> findBaseClass = clazz;
        PluginMap findPluginMap = PluginMap.EMPTY;

        Class<?> ptr = clazz;
        while (ptr != null) {
            Pluggable pluggable = ptr.getAnnotation(Pluggable.class);
            if (pluggable != null) {
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

        if (config.root().size() != 1) {
            throw new ConfigException.Parse(config.root().origin(),
                                            "config root must have exactly one key");
        }
        String category = config.root().keySet().iterator().next();
        PluginMap pluginMap = pluginRegistry.asMap().get(category);
        if (pluginMap == null) {
            throw new ConfigException.BadValue(config.root().get(category).origin(),
                                               category,
                                               "top level key must be a valid category");
        }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

    }

    /** called when the expected type is a non-standard object */
    private <T> T hydrateObject(Class<T> type, ConfigValue configValue) {
        CodableClassInfo info = getOrCreateClassInfo(type);
        PluginMap pluginMap = info.getPluginMap();
        return hydrateObject(info, pluginMap, type, configValue);
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

    @Override
    public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType) {
        Pluggable pluggable = ac.getAnnotation(Pluggable.class);
        if (pluggable != null) {
            PluginMap pluginMap = pluginRegistry.byCategory().get(pluggable.value());
            if (pluginMap != null) {
                return new CodecTypeResolverBuilder(pluginMap, config.getTypeFactory(), pluginRegistry);
            } else {
                log.warn("missing plugin map for {}, reached from {}", pluggable.value(), ac.getRawType());
            }
        } else if (pluginRegistry.byClass().containsKey(ac.getRawType())) {
            PluginMap pluginMap = pluginRegistry.byClass().get(ac.getRawType());
            return new CodecTypeResolverBuilder(pluginMap, config.getTypeFactory(), pluginRegistry);
        }
        return null;
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

    /** report all non-alias plugin types */
    @Override
    public List<NamedType> findSubtypes(Annotated a) {
        Pluggable pluggable = a.getAnnotation(Pluggable.class);
        PluginMap pluginMap;
        if (pluggable != null) {
            pluginMap = pluginRegistry.byCategory().get(pluggable.value());
        } else if (pluginRegistry.byClass().containsKey(a.getRawType())) {
            pluginMap = pluginRegistry.byClass().get(a.getRawType());
        } else {
            return null;
        }
        List<NamedType> result = new ArrayList<>(pluginMap.asBiMap().size());
        for (Map.Entry<String, Class<?>> type : pluginMap.asBiMap().entrySet()) {
            result.add(new NamedType(type.getValue(), type.getKey()));
        }
        return result;
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

        if (config.root().size() != 1) {
            throw new ConfigException.Parse(config.root().origin(),
                                            "config root must have exactly one key");
        }
        String category = config.root().keySet().iterator().next();
        PluginMap pluginMap = pluginRegistry.asMap().get(category);
        if (pluginMap == null) {
            throw new ConfigException.BadValue(config.root().get(category).origin(),
                                               category,
                                               "top level key must be a valid category");
        }
        Class<?> baseClass = Objects.firstNonNull(pluginMap.baseClass(), Object.class);
        return expandSugar(baseClass, config.root().get(category), pluginRegistry);
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

            return ConfigValueFactory.fromAnyRef(config.unwrapped(),
                                                 "unchanged for raw ConfigValue field "
                                                 + config.origin().description());
        }
        CodableClassInfo typeInfo = new CodableClassInfo(type, pluginRegistry.config(), pluginRegistry);
        PluginMap pluginMap = typeInfo.getPluginMap();
        ConfigValue valueOrResolvedRoot = resolveType(type, config, pluginMap);
        if (valueOrResolvedRoot.valueType() != ConfigValueType.OBJECT) {
            return valueOrResolvedRoot;
        }
        ConfigObject root = (ConfigObject) valueOrResolvedRoot;
        String classField = pluginMap.classField();
        if (root.get(classField) != null) {
            try {
                type = pluginMap.getClass((String) root.get(classField).unwrapped());
            } catch (ClassNotFoundException ignored) {
                // try not to throw exceptions or at least checked exceptions from this helper method
            }
        }
        return expandSugarSkipResolve(type, root, pluginRegistry);
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

     * {@link #decodeObject(String, Config)} with the resultant config and the passed in category. Pretty much just
     * a convenience function for simple use cases that don't want to care about how ConfigFactory works.
     */
    public <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") String configText)
            throws JsonProcessingException, IOException {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        Config config = ConfigFactory.parseString(configText).resolve();
        return (T) decodeObject(pluginMap.baseClass(), config);
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

     * field and type information for the object to be constructed. Global defaults, plugin configuration, etc, are
     * provided by this CodecConfig instance's globalConfig and pluginRegistry fields.
     */
    public <T> T decodeObject(@Nonnull String category, @Nonnull Config config)
            throws JsonProcessingException, IOException {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        return (T) decodeObject(pluginMap.baseClass(), config);
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

        if (config.root().size() != 1) {
            throw new ConfigException.Parse(config.root().origin(),
                                            "config root must have exactly one key");
        }
        String category = config.root().keySet().iterator().next();
        PluginMap pluginMap = pluginRegistry.asMap().get(category);
        if (pluginMap == null) {
            throw new ConfigException.BadValue(config.root().get(category).origin(),
                                               category,
                                               "top level key must be a valid category");
        }
        ConfigValue configValue = config.root().get(category);
        return (T) decodeObject(pluginMap.baseClass(), configValue);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.