adalid.util.meta.sql.PlatformBean.java Source code

Java tutorial

Introduction

Here is the source code for adalid.util.meta.sql.PlatformBean.java

Source

/*
 * Este programa es software libre; usted puede redistribuirlo y/o modificarlo bajo los terminos
 * de la licencia "GNU General Public License" publicada por la Fundacion "Free Software Foundation".
 * Este programa se distribuye con la esperanza de que pueda ser util, pero SIN NINGUNA GARANTIA;
 * vea la licencia "GNU General Public License" para obtener mas informacion.
 */
package adalid.util.meta.sql;

import java.io.File;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

/**
 * @author Jorge Campins
 */
public class PlatformBean {

    private static final Logger logger = Logger.getLogger(PlatformBean.class);

    // <editor-fold defaultstate="collapsed" desc="instance fields">
    private final String _name;

    private final File _propertiesFile;

    private final Map<String, TemplateBean> _templates;
    // </editor-fold>

    public PlatformBean(String name, File propertiesFile) {
        _name = name;
        _propertiesFile = propertiesFile;
        _templates = new TreeMap<>();
    }

    // <editor-fold defaultstate="collapsed" desc="instance fields' public getters and setters">
    /**
     * @return the name
     */
    public String getName() {
        return _name;
    }

    /**
     * @return the properties file
     */
    public File getPropertiesFile() {
        return _propertiesFile;
    }

    /**
     * @return the templates
     */
    public Map<String, TemplateBean> getTemplatesMap() {
        return _templates;
    }
    // </editor-fold>

    public void add(TemplateBean template) {
        String path = template.getPropertiesFile().getPath();
        String text;
        if (StringUtils.isBlank(path)) {
            text = "a null path template will not added to platform " + _name;
            logger.error(text);
        } else if (_templates.containsKey(path)) {
            text = "template " + path + " already added to platform " + _name;
            logger.error(text);
        } else {
            _templates.put(path, template);
        }
    }

}