it.vige.cities.Normalizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cities-generator Show documentation
Show all versions of cities-generator Show documentation
Generate a file with the cities of your country
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;
}
}