<commit_before>/*
 * This work is licensed under the Creative Commons Attribution 3.0 Unported
 * License. To view a copy of this license, visit
 * http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative
 * Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
 */
package org.tros.utils;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;
import org.tros.torgo.TorgoToolkit;

/**
 *
 * @author matta
 */
public abstract class PropertiesInitializer {

    private static final Object LOCK = new Object();
    private static final org.tros.utils.logging.Logger LOGGER = org.tros.utils.logging.Logging.getLogFactory().getLogger(PropertiesInitializer.class);

    @SuppressWarnings("OverridableMethodCallInConstructor")
    protected PropertiesInitializer() {
        synchronized (LOCK) {
            this.initializeHelper();

            String dir = null;
            if (!BuildInfo.class.isAssignableFrom(this.getClass())) {
                dir = PathUtils.getApplicationConfigDirectory(TorgoToolkit.getBuildInfo());
            }

            this.initializeFromProperties();
            this.initializeFromProperties(dir);
        }
    }

    /**
     * Initialize from properties file if possible.
     *
     * @param dir the directory to search for properties files.
     */
    private void initializeFromProperties(String dir) {
        if (dir == null) {
            return;
        }
        Properties prop = new Properties();

        String propFile = dir + '/' + this.getClass().getSimpleName() + ".properties";<commit_msg>Fixed missed coverage ignore<commit_after>/*
 * This work is licensed under the Creative Commons Attribution 3.0 Unported
 * License. To view a copy of this license, visit
 * http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative
 * Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
 */
package org.tros.utils;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;
import org.tros.torgo.TorgoToolkit;

/**
 *
 * @author matta
 */
public abstract class PropertiesInitializer {

    private static final Object LOCK = new Object();
    private static final org.tros.utils.logging.Logger LOGGER = org.tros.utils.logging.Logging.getLogFactory().getLogger(PropertiesInitializer.class);

    @SuppressWarnings("OverridableMethodCallInConstructor")
    protected PropertiesInitializer() {
        synchronized (LOCK) {
            this.initializeHelper();

            String dir = null;
            if (!BuildInfo.class.isAssignableFrom(this.getClass())) {
                dir = PathUtils.getApplicationConfigDirectory(TorgoToolkit.getBuildInfo());
            }

            this.initializeFromProperties();
            this.initializeFromProperties(dir);
        }
    }

    /**
     * Initialize from properties file if possible.
     *
     * @param dir the directory to search for properties files.
     */
    @CoverageIgnore
    private void initializeFromProperties(String dir) {
        if (dir == null) {
            return;
        }
        Properties prop = new Properties();

        String propFile = dir + '/' + this.getClass().getSimpleName() + ".properties";
{'fraction_non_alphanumeric': 0.10028954988154777, 'fraction_numerical': 0.007896814951302974, 'mean_word_length': 3.2081949058693247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3952014', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1007, 'n_words': 265}