<commit_before>/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2006-2012 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/
package org.opennms.features.vaadin.dashboard.model;

import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import org.opennms.features.vaadin.dashboard.config.ui.PropertiesWindow;

import java.util.Map;
import java.util.TreeMap;

/**
 * This class represents an abstract factory for instantiating {@link Dashlet} objects.
 *
 * @author <NAME>
 */
public abstract class AbstractDashletFactory implements DashletFactory {
    /**
     * The name of the provided {@link Dashlet}
     */
    protected String m_name;
    /**
     * A map holding the required parameters for the {@link Dashlet}
     */
    protected Map<String, String> m_requiredParameters = new TreeMap<String, String>();
    /**
     * A map holding the required parameter descriptions for the {@link Dashlet}
     */
    protected Map<String, String> m_requiredParameterDescriptions = new TreeMap<String, String>();

    /**
     * Constructor for instantiating a new factory.
     */
    public AbstractDashletFactory() {
    }

    /**
     * Constructor for instantiating a new factory with the given name.
     *
     * @param name the dashlet's name
     */
    public AbstractDashletFactory(String name) {
        m_name = name;
    }

    /**
     * Add a required parameter for this factory.
     *
     * @param key          the key to use
     * @param defaultValue the default value for this parameter
     */
    protected void addRequiredParameter(String key, String defaultValue) {
        m_requiredParameters.put(key, defaultValue);
    }

    /**
     * Returns the name of the {@link Dashlet} instances this object provides.
     *
     * @return the name
     */
    public String getName() {
        return m_name;
    }

    /**
     * Sets the name of the {@link Dashlet} instances this object provides.
     *
     * @param name the name
     */
    public void setName(String name) {
        m_name = name;
    }

    /**
     * Returns the {@link Map} with the required parameters and default values.
     *
     * @return the {@link Map} holding the requires parameters
     */
    public Map<String, String> getRequiredParameters() {
        return m_requiredParameters;
    }

    /**
     * Returns the {@link Map} with the required parameter descriptions.
     *
     * @return the {@link Map} holding the requires parameter descriptions
     */
    public Map<String, String> getRequiredParameterDescriptions() {
        return m_requiredParameterDescriptions;
    }

    /**
     * This method sets the required parameters {@link Map}.
     *
     * @param requiredParameters the parameter {@link Map} to be set
     */
    public void setRequiredParameters(Map<String, String> requiredParameters) {
        m_requiredParameters = requiredParameters;
    }

    /**
     * This method sets the required parameter descriptions {@link Map}.
     *
     * @param requiredParameterDescriptions the parameter description {@link Map} to be set
     */<commit_msg>Added TreeMap for natural ordering of required parameters<commit_after>/*******************************************************************************
 * This file is part of OpenNMS(R).
 *
 * Copyright (C) 2006-2012 The OpenNMS Group, Inc.
 * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 *
 * OpenNMS(R) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * OpenNMS(R) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenNMS(R).  If not, see:
 *      http://www.gnu.org/licenses/
 *
 * For more information contact:
 *     OpenNMS(R) Licensing <<EMAIL>>
 *     http://www.opennms.org/
 *     http://www.opennms.com/
 *******************************************************************************/
package org.opennms.features.vaadin.dashboard.model;

import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import org.opennms.features.vaadin.dashboard.config.ui.PropertiesWindow;

import java.util.Map;
import java.util.TreeMap;

/**
 * This class represents an abstract factory for instantiating {@link Dashlet} objects.
 *
 * @author <NAME>
 */
public abstract class AbstractDashletFactory implements DashletFactory {
    /**
     * The name of the provided {@link Dashlet}
     */
    protected String m_name;
    /**
     * A map holding the required parameters for the {@link Dashlet}
     */
    protected Map<String, String> m_requiredParameters = new TreeMap<String, String>();
    /**
     * A map holding the required parameter descriptions for the {@link Dashlet}
     */
    protected Map<String, String> m_requiredParameterDescriptions = new TreeMap<String, String>();

    /**
     * Constructor for instantiating a new factory.
     */
    public AbstractDashletFactory() {
    }

    /**
     * Constructor for instantiating a new factory with the given name.
     *
     * @param name the dashlet's name
     */
    public AbstractDashletFactory(String name) {
        m_name = name;
    }

    /**
     * Add a required parameter for this factory.
     *
     * @param key          the key to use
     * @param defaultValue the default value for this parameter
     */
    protected void addRequiredParameter(String key, String defaultValue) {
        m_requiredParameters.put(key, defaultValue);
    }

    /**
     * Returns the name of the {@link Dashlet} instances this object provides.
     *
     * @return the name
     */
    public String getName() {
        return m_name;
    }

    /**
     * Sets the name of the {@link Dashlet} instances this object provides.
     *
     * @param name the name
     */
    public void setName(String name) {
        m_name = name;
    }

    /**
     * Returns the {@link Map} with the required parameters and default values.
     *
     * @return the {@link Map} holding the requires parameters
     */
    public Map<String, String> getRequiredParameters() {
        return m_requiredParameters;
    }

    /**
     * Returns the {@link Map} with the required parameter descriptions.
     *
     * @return the {@link Map} holding the requires parameter descriptions
     */
    public Map<String, String> getRequiredParameterDescriptions() {
        return m_requiredParameterDescriptions;
    }

    /**
     * This method sets the required parameters {@link Map}.
     *
     * @param requiredParameters the parameter {@link Map} to be set
     */
    public void setRequiredParameters(Map<String, String> requiredParameters) {
        m_requiredParameters = new TreeMap<String, String>(requiredParameters);
    }

    /**
     * This method sets the required parameter descriptions {@link Map}.
     *
     * @param requiredParameterDescriptions the parameter description {@link Map} to be set
     */
{'fraction_non_alphanumeric': 0.12492682355696054, 'fraction_numerical': 0.003980798501346447, 'mean_word_length': 2.999063670411985, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4746117', 'n_tokens_mistral': 2319, 'n_tokens_neox': 2224, 'n_words': 823}