All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.vige.cities.Normalizer Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package it.vige.cities;

import java.util.List;

/**
 * 
 * @author lucastancapiano
 *
 *         Normalizer for the names of the cities. According the configuration
 *         they will be formatted
 */
public class Normalizer {

	/**
	 * 
	 * @param caseSensitive case sensitive parameter
	 * @param duplicatedNames duplicated names parameter
	 * @param text text
	 * @param lines lines
	 * @return the command line
	 */
	public static String execute(boolean caseSensitive, boolean duplicatedNames, final String text,
			List lines) {
		String newText = text;
		if (!duplicatedNames) {
			long count = lines.parallelStream().filter(e -> e.equalsIgnoreCase(text)).count();
			for (int i = 0; i < count; i++)
				newText = newText + " (" + (i + 2) + ")";
		}
		if (!caseSensitive)
			newText = newText.toUpperCase();
		return newText;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy