Package com.addthis.codec.plugins

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


    }

    /** 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

        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

     * 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

     * 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, @Syntax("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

        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

    }

    /** 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

    Map hydrateMap(CodableFieldInfo field, Config config, @Nullable Object objectShell) {
        Class<?> type = field.getTypeOrComponentType();
        Map map;
        if (Modifier.isAbstract(type.getModifiers()) || Modifier.isInterface(type.getModifiers())) {
            PluginMap typeMap = pluginRegistry.byClass().get(type);
            @Nullable Class<?> defaultType;
            if (typeMap != null) {
                defaultType = typeMap.defaultSugar();
            } else {
                defaultType = null;
            }
            if (defaultType != null) {
                try {
View Full Code Here

    Collection hydrateCollection(CodableFieldInfo field, Config config, @Nullable Object objectShell) {
        Class<?> type = field.getTypeOrComponentType();
        Collection<Object> col;
        if (Modifier.isAbstract(type.getModifiers()) || Modifier.isInterface(type.getModifiers())) {
            PluginMap typeMap = pluginRegistry.byClass().get(type);
            @Nullable Class<?> defaultType;
            if (typeMap != null) {
                defaultType = typeMap.defaultSugar();
            } else {
                defaultType = null;
            }
            if (defaultType != null) {
                try {
View Full Code Here

                        onlyObject = onlyObject.withFallback(
                                resolvedConfig.getValue(primaryFieldName).atKey(onlyUnusedKey));
                    }
                    CodableClassInfo primaryInfo = getOrCreateClassInfo(
                            field.getTypeOrComponentType());
                    PluginMap primaryMap = primaryInfo.getPluginMap();
                    value = hydrateSingleKeyObject(primaryMap, onlyObject);
                    if (value != null) {
                        usedPrimaryField = true;
                    } else {
                        throw new ConfigException.BadPath(config.origin(), "unrecognized key(s) " + unusedKeys.toString());
View Full Code Here

TOP

Related Classes of com.addthis.codec.plugins.PluginMap

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.