Examples of PluginMap


Examples of com.addthis.codec.plugins.PluginMap

        return validate(value);
    }

    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

        return decodeObject(type, config);
    }

    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

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 codable object, but we know very little about it */
    private <T> T hydrateObject(Class<T> type, ConfigValue configValue) {
        CodableClassInfo info = getOrCreateClassInfo(type);
        PluginMap pluginMap = info.getPluginMap();
        return hydrateValueAsObject(info, pluginMap, type, configValue);
    }
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 = codec.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), codec);
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

        return expandSugar(baseClass, config.root().get(category), codec);
    }

    public static ConfigObject expandSugar(Class<?> type, ConfigValue config, CodecConfig codec) {
        CodableClassInfo typeInfo = codec.getOrCreateClassInfo(type);
        PluginMap pluginMap = typeInfo.getPluginMap();
        ConfigObject root = resolveType(type, config, pluginMap);
        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, codec);
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

        return hydrateObject(classInfo, classInfo.getPluginMap(), type, ConfigFactory.empty().root());
    }

    /** Construct an object of the requested plugin category based on the default type and values */
    public <T> T newDefault(@Nonnull String category) {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        return hydrateObject(null, pluginMap, null, ConfigFactory.empty().root());
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

     * Instantiate an object of the requested category based on the provided config. The config should only contain
     * 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) {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        return hydrateObject(null, pluginMap, null, config.root());
    }
View Full Code Here

Examples of com.addthis.codec.plugins.PluginMap

     * Tries to parse the string as an isolated typesafe-config object, tries to resolve it, and then calls
     * {@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, @Language("HOCON") @Nonnull String configText) {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        Config config = ConfigFactory.parseString(configText).resolve();
        return hydrateObject(null, pluginMap, null, config.root());
    }
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.