All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sealights.onpremise.agents.plugin.PluginConfigurationParser Maven / Gradle / Ivy

package io.sealights.onpremise.agents.plugin;

import org.apache.maven.model.Plugin;
import org.codehaus.plexus.util.xml.Xpp3Dom;

public class PluginConfigurationParser {
    
    public static Boolean extractBooleanValue(Xpp3Dom cfg, String name) {
        String rawValue = extractStringValue(cfg, name);
        return rawValue != null ? Boolean.parseBoolean(rawValue) : null;
    }

    public static Integer extractIntegerValue(Xpp3Dom cfg, String name) {
        String rawValue = extractStringValue(cfg, name);
        return rawValue != null ? Integer.parseInt(rawValue) : null;
    }

    public static String extractStringValue(Xpp3Dom cfg, String name) {
        if (cfg == null) {
            return null;
        }
        Xpp3Dom[] values = cfg.getChildren(name);
        if (values != null && values.length > 0) {
            return values[0].getValue();
        } else {
            return null;
        }
    }

    public static Xpp3Dom extractConfiguration(Plugin plugin) {
        Object configurationObject = plugin.getConfiguration();
        if (configurationObject != null) {
            return (Xpp3Dom) configurationObject;
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy