<commit_before>/*
 * Copyright 2016 EPAM Systems
 * 
 * 
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/commons-dao
 * 
 * Report Portal 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.
 * 
 * Report Portal 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 Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.epam.ta.reportportal.commons;

import com.google.common.base.Preconditions;

import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.stream.Collectors.toList;
import static java.util.stream.StreamSupport.stream;

/**
 * Some useful utils for working with entities<br>
 * For example: usernames, project names, tags, etc.
 *
 * @author <NAME>
 */
public class EntityUtils {

	private EntityUtils() {

	}

	/**
	 * Normalize any ID for database ID fields, for example
	 *
	 * @param id ID to normalize
	 * @return String
	 */
	public static String normalizeId(String id) {
		return Preconditions.checkNotNull(id, "Provided value shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided user name
	 *
	 * @param username Username to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeUsername(String username) {
		return Preconditions.checkNotNull(username, "Username shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided project name
	 *
	 * @param projectName Project to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeProjectName(String projectName) {
		return Preconditions.checkNotNull(projectName, "Project name shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided email address
	 *
	 * @param email email to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeEmail(String email) {
		return Preconditions.checkNotNull(email, "Email shouldn't be null").toLowerCase();
	}

	/**
	 * Remove leading and trailing spaces from list of string
	 *
	 * @param strings Strings to trim
	 * @return String
	 */
	public static Iterable<String> trimStrings(Iterable<String> strings) {
		Preconditions.checkNotNull(strings, "List of strings shouldn't be null");
		return stream(strings.spliterator(), false).filter(string -> !isNullOrEmpty(string)).map(String::trim).collect(toList());
	}

	/**
	 * Convert declined symbols on allowed for WS and UI
	 *
	 * @param input Input to be escaped
	 * @return Updated input
	 */
	public static Iterable<String> update(Iterable<String> input) {
		final String oldSeparator = ",";
		final String newSeparator = "_";
		final String backSlashSymbol = "\\";
		return stream(input.spliterator(), false).map(
				string -> string.replace(oldSeparator, newSeparator).replace(backSlashSymbol, "\\\\")).collect(toList());
	}
}<commit_msg>fix some unused symbols in string updating<commit_after>/*
 * Copyright 2016 EPAM Systems
 * 
 * 
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/commons-dao
 * 
 * Report Portal 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.
 * 
 * Report Portal 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 Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.epam.ta.reportportal.commons;

import com.google.common.base.Preconditions;

import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.stream.Collectors.toList;
import static java.util.stream.StreamSupport.stream;

/**
 * Some useful utils for working with entities<br>
 * For example: usernames, project names, tags, etc.
 *
 * @author <NAME>
 */
public class EntityUtils {

	private EntityUtils() {

	}

	/**
	 * Normalize any ID for database ID fields, for example
	 *
	 * @param id ID to normalize
	 * @return String
	 */
	public static String normalizeId(String id) {
		return Preconditions.checkNotNull(id, "Provided value shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided user name
	 *
	 * @param username Username to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeUsername(String username) {
		return Preconditions.checkNotNull(username, "Username shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided project name
	 *
	 * @param projectName Project to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeProjectName(String projectName) {
		return Preconditions.checkNotNull(projectName, "Project name shouldn't be null").toLowerCase();
	}

	/**
	 * Normalized provided email address
	 *
	 * @param email email to normalize
	 * @return String
	 * @deprecated in favor of {@link #normalizeId(String)}
	 */
	@Deprecated
	public static String normalizeEmail(String email) {
		return Preconditions.checkNotNull(email, "Email shouldn't be null").toLowerCase();
	}

	/**
	 * Remove leading and trailing spaces from list of string
	 *
	 * @param strings Strings to trim
	 * @return String
	 */
	public static Iterable<String> trimStrings(Iterable<String> strings) {
		Preconditions.checkNotNull(strings, "List of strings shouldn't be null");
		return stream(strings.spliterator(), false).filter(string -> !isNullOrEmpty(string)).map(String::trim).collect(toList());
	}

	/**
	 * Convert declined symbols on allowed for WS and UI
	 *
	 * @param input Input to be escaped
	 * @return Updated input
	 */
	public static Iterable<String> update(Iterable<String> input) {
		final String oldSeparator = ",";
		final String newSeparator = "_";
		return stream(input.spliterator(), false).map(
				string -> string.replace(oldSeparator, newSeparator)).collect(toList());
	}
}
{'fraction_non_alphanumeric': 0.10300429184549356, 'fraction_numerical': 0.001479946721918011, 'mean_word_length': 4.150914634146342, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '137574', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1811, 'n_words': 670}