<commit_before>/*******************************************************************************
 * Copyright 2012 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.sf.uadetector;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

import net.sf.uadetector.internal.util.AlphanumComparator;

/**
 * The {@code VersionNumber} class represents the version number of an operating system or User-Agent.<br>
 * <br>
 * A {@code VersionNumber} object is immutable, their values cannot be changed after creation.
 * 
 * @author <NAME>
 */
public final class VersionNumber implements ReadableVersionNumber {

	/**
	 * Empty extension of a version number
	 */
	public static final String EMPTY_EXTENSION = "";

	/**
	 * Empty group or category of a version number
	 */
	public static final String EMPTY_GROUP = "";

	/**
	 * Defines an empty or not set version number
	 */
	public static final VersionNumber UNKNOWN = new VersionNumber(EMPTY_GROUP);

	/**
	 * Separator between numeric groups of a version number
	 */
	private static final char SEPARATOR = '.';

	/**
	 * Minimum number of numeric group a version number
	 */
	private static final int MIN_GROUP_SIZE = 3;

	/**
	 * Regular expression to find only numerical values ​​in strings
	 */
	private static final Pattern NUMERIC = Pattern.compile("\\d+");

	/**
	 * Checks a string that only numerical values ​​are present. Negative numbers are not included.
	 * 
	 * @param text
	 *            string to be tested
	 * @return {@code true} if only numeric characters are present, otherwise {@code false}
	 */
	private static final boolean isNumeric(final String text) {
		return NUMERIC.matcher(text).matches();
	}

	/**
	 * Replaces all {@code null} values in the given list of groups with {@code VersionNumber#EMPTY_GROUP}.
	 * 
	 * @param groups
	 *            list of numbers of a version number
	 * @return a new list of groups without {@code null} values
	 */
	public static List<String> replaceNullValueWithEmptyGroup(final List<String> groups) {
		if (groups == null) {
			throw new IllegalArgumentException("Argument 'groups' must not be null.");
		}

		final List<String> result = new ArrayList<String>(groups.size());
		for (final String group : groups) {
			if (group == null) {
				result.add(EMPTY_GROUP);
			} else {<commit_msg>Unnecessary final modifier in final class removed<commit_after>/*******************************************************************************
 * Copyright 2012 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.sf.uadetector;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

import net.sf.uadetector.internal.util.AlphanumComparator;

/**
 * The {@code VersionNumber} class represents the version number of an operating system or User-Agent.<br>
 * <br>
 * A {@code VersionNumber} object is immutable, their values cannot be changed after creation.
 * 
 * @author <NAME>ouél
 */
public final class VersionNumber implements ReadableVersionNumber {

	/**
	 * Empty extension of a version number
	 */
	public static final String EMPTY_EXTENSION = "";

	/**
	 * Empty group or category of a version number
	 */
	public static final String EMPTY_GROUP = "";

	/**
	 * Defines an empty or not set version number
	 */
	public static final VersionNumber UNKNOWN = new VersionNumber(EMPTY_GROUP);

	/**
	 * Separator between numeric groups of a version number
	 */
	private static final char SEPARATOR = '.';

	/**
	 * Minimum number of numeric group a version number
	 */
	private static final int MIN_GROUP_SIZE = 3;

	/**
	 * Regular expression to find only numerical values ​​in strings
	 */
	private static final Pattern NUMERIC = Pattern.compile("\\d+");

	/**
	 * Checks a string that only numerical values ​​are present. Negative numbers are not included.
	 * 
	 * @param text
	 *            string to be tested
	 * @return {@code true} if only numeric characters are present, otherwise {@code false}
	 */
	private static boolean isNumeric(final String text) {
		return NUMERIC.matcher(text).matches();
	}

	/**
	 * Replaces all {@code null} values in the given list of groups with {@code VersionNumber#EMPTY_GROUP}.
	 * 
	 * @param groups
	 *            list of numbers of a version number
	 * @return a new list of groups without {@code null} values
	 */
	public static List<String> replaceNullValueWithEmptyGroup(final List<String> groups) {
		if (groups == null) {
			throw new IllegalArgumentException("Argument 'groups' must not be null.");
		}

		final List<String> result = new ArrayList<String>(groups.size());
		for (final String group : groups) {
			if (group == null) {
				result.add(EMPTY_GROUP);
			} else {
{'fraction_non_alphanumeric': 0.14143094841930118, 'fraction_numerical': 0.002995008319467554, 'mean_word_length': 3.9109477124183005, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2278912', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1514, 'n_words': 645}