<commit_before>package com.bloatit.web.utils;

import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;

import com.bloatit.common.FatalErrorException;

/**
 * Class to handle tools related to countries managements.
 */
public class Countries {
	
	private static final String COUNTRIES_PATH = "i18n/countries";
	private static Set<Country> availableCountries = null;
	
	/**
	 * <p>Lists all available countries ordered on their fullname</p>
	 * @return a list of the available countries
	 */
	public static Set<Country> getAvailableCountries(){
		if(availableCountries == null){
			availableCountries = new TreeSet<Country>();
			initAvailableCountries();
		}
		return availableCountries;
	}
	
	
	
	private static void initAvailableCountries(){
		try {
			Properties properties = PropertyLoader.loadProperties(COUNTRIES_PATH);
			for(Entry<?, ?> property : properties.entrySet()){
				String key = (String)property.getKey();
				String value = (String)property.getValue();
				availableCountries.add(new Country(value, key));
			}
		} catch (IOException e) {
			throw new FatalErrorException("File describing available countries is not available at "+COUNTRIES_PATH, e);
		}
	}
	
	/**
	 * Nested class to represent a country
	 */
	public static class Country implements Comparable<Country>{
		public String name;
		public String code;

		public Country(String name, String code) {
			super();
			this.name = name;
			this.code = code;
		}

		@Override
		public int compareTo(Country o) {
			return this.name.compareTo(o.name);
		}
	}
}<commit_msg>Fix sonar warning: Bad practice - Class defines compareTo(...) and uses Object.equals()<commit_after>package com.bloatit.web.utils;

import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;

import com.bloatit.common.FatalErrorException;

/**
 * Class to handle tools related to countries managements.
 */
public class Countries {
	
	private static final String COUNTRIES_PATH = "i18n/countries";
	private static Set<Country> availableCountries = null;
	
	/**
	 * <p>Lists all available countries ordered on their fullname</p>
	 * @return a list of the available countries
	 */
	public static Set<Country> getAvailableCountries(){
		if(availableCountries == null){
			availableCountries = new TreeSet<Country>();
			initAvailableCountries();
		}
		return availableCountries;
	}
	
	
	
	private static void initAvailableCountries(){
		try {
			Properties properties = PropertyLoader.loadProperties(COUNTRIES_PATH);
			for(Entry<?, ?> property : properties.entrySet()){
				String key = (String)property.getKey();
				String value = (String)property.getValue();
				availableCountries.add(new Country(value, key));
			}
		} catch (IOException e) {
			throw new FatalErrorException("File describing available countries is not available at "+COUNTRIES_PATH, e);
		}
	}
	
	/**
	 * Nested class to represent a country
	 */
	public static class Country implements Comparable<Country>{
		public String name;
		public String code;

		public Country(String name, String code) {
			super();
			this.name = name;
			this.code = code;
		}

		@Override
		public int compareTo(Country o) {
			return this.name.compareTo(o.name);
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Country other = (Country) obj;
			if (name == null) {
				if (other.name != null)
					return false;
			} else if (!name.equals(other.name))
				return false;
			return true;
		}

		
		
	}
}
{'fraction_non_alphanumeric': 0.11002710027100271, 'fraction_numerical': 0.001084010840108401, 'mean_word_length': 3.908244680851064, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '3135556', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1073, 'n_words': 315}