<commit_before>package au.com.agic.apptesting.utils.impl;

import static com.google.common.base.Preconditions.checkArgument;

import au.com.agic.apptesting.constants.Constants;
import au.com.agic.apptesting.utils.SystemPropertyUtils;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * Implementation that deals with the restrictions imposed by web start
 */
@Component
public class SystemPropertyUtilsImpl implements SystemPropertyUtils {

	/**
	 * These are the prefixes that can be applied to any system property. This is mostly to
	 * facilitate web start, which has restrictions on system properties. See
	 * http://stackoverflow.com/questions/19400725/with-java-7-update-45-the-system-properties-no-longer-set-from-jnlp-tag-proper
	 * for details.
	 */
	private static final List<String> SYSTEM_PROPERTY_PREFIXES = Arrays.asList("", "jnlp.", "javaws.");

	private static final SystemPropertyUtils SYSTEM_PROPERTY_UTILS = new SystemPropertyUtilsImpl();

	@Override
	public String getProperty(final String name) {
		checkArgument(StringUtils.isNotBlank(name));

		return SYSTEM_PROPERTY_PREFIXES.stream()
			.map(e -> System.getProperty(e + name))
			.filter(Objects::nonNull)
			.findFirst()
			.orElse(null);
	}

	@Override
	public boolean getPropertyAsBoolean(final String name, boolean defaultValue) {
		checkArgument(StringUtils.isNotBlank(name));

		Optional.ofNullable(SYSTEM_PROPERTY_UTILS.getProperty(name))
			.map(String::toLowerCase)
			.map(String::trim)
			.map(Boolean::parseBoolean)
			.orElse(defaultValue);
	}

	@Override
	public String getPropertyEmptyAsNull(final String name) {
		checkArgument(StringUtils.isNotBlank(name));

		return SYSTEM_PROPERTY_PREFIXES.stream()
			.map(e -> System.getProperty(e + name))
			.filter(StringUtils::isNotBlank)
			.findFirst()<commit_msg>Added the ability to enable or disable monochrome output<commit_after>package au.com.agic.apptesting.utils.impl;

import static com.google.common.base.Preconditions.checkArgument;

import au.com.agic.apptesting.constants.Constants;
import au.com.agic.apptesting.utils.SystemPropertyUtils;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * Implementation that deals with the restrictions imposed by web start
 */
@Component
public class SystemPropertyUtilsImpl implements SystemPropertyUtils {

	/**
	 * These are the prefixes that can be applied to any system property. This is mostly to
	 * facilitate web start, which has restrictions on system properties. See
	 * http://stackoverflow.com/questions/19400725/with-java-7-update-45-the-system-properties-no-longer-set-from-jnlp-tag-proper
	 * for details.
	 */
	private static final List<String> SYSTEM_PROPERTY_PREFIXES = Arrays.asList("", "jnlp.", "javaws.");

	private static final SystemPropertyUtils SYSTEM_PROPERTY_UTILS = new SystemPropertyUtilsImpl();

	@Override
	public String getProperty(final String name) {
		checkArgument(StringUtils.isNotBlank(name));

		return SYSTEM_PROPERTY_PREFIXES.stream()
			.map(e -> System.getProperty(e + name))
			.filter(Objects::nonNull)
			.findFirst()
			.orElse(null);
	}

	@Override
	public boolean getPropertyAsBoolean(final String name, boolean defaultValue) {
		checkArgument(StringUtils.isNotBlank(name));

		return Optional.ofNullable(SYSTEM_PROPERTY_UTILS.getProperty(name))
			.map(String::toLowerCase)
			.map(String::trim)
			.map(Boolean::parseBoolean)
			.orElse(defaultValue);
	}

	@Override
	public String getPropertyEmptyAsNull(final String name) {
		checkArgument(StringUtils.isNotBlank(name));

		return SYSTEM_PROPERTY_PREFIXES.stream()
			.map(e -> System.getProperty(e + name))
			.filter(StringUtils::isNotBlank)
			.findFirst()
{'fraction_non_alphanumeric': 0.10705712914066251, 'fraction_numerical': 0.005760921747479597, 'mean_word_length': 5.332826747720365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '378467', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1247, 'n_words': 264}