<commit_before>/*
 * Copyright 2014 <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 com.github.dannil.scbjavaclient.client.population.statistic;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.github.dannil.scbjavaclient.client.AbstractClient;
import com.github.dannil.scbjavaclient.model.population.statistic.AverageAge;
import com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth;
import com.github.dannil.scbjavaclient.model.population.statistic.Population;
import com.github.dannil.scbjavaclient.utility.JsonUtility;
import com.github.dannil.scbjavaclient.utility.ListUtility;
import com.github.dannil.scbjavaclient.utility.QueryBuilder;

/**
 * Client which handles population statistics data fetching.
 * 
 * @author <NAME>
 */
public class PopulationStatisticsClient extends AbstractClient {

	/**
	 * Default constructor.
	 */
	public PopulationStatisticsClient() {
		super();
	}

	/**
	 * Overloaded constructor.
	 * 
	 * @param locale
	 *            the locale for this client
	 */
	public PopulationStatisticsClient(Locale locale) {
		super(locale);
	}

	// public List<String> getRegions() {
	// return super.getRegions(getUrl());
	// }

	// public List<Integer> getYears() {
	// List<String> fetchedYears = super.getYears(getUrl());
	//
	// List<Integer> years = new ArrayList<Integer>(fetchedYears.size());
	// for (String fetchedYear : fetchedYears) {
	// years.add(Integer.valueOf(fetchedYear));
	// }
	// return years;
	// }

	/**
	 * Fetch all average age data.
	 * 
	 * @return the average age data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.AverageAge
	 *         AverageAge} objects
	 * 
	 * @see PopulationStatisticsClient#getAverageAge(Collection, Collection, Collection)
	 */
	public List<AverageAge> getAverageAge() {
		return this.getAverageAge(null, null, null);
	}

	/**
	 * Fetch all average age data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the average age data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.AverageAge
	 *         AverageAge} objects
	 */
	public List<AverageAge> getAverageAge(Collection<String> regions, Collection<String> genders,
			Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", ListUtility.toList("BE0101G9"));
		mappings.put("Region", regions);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101B/BefolkningMedelAlder", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, AverageAge.class);
	}

	/**
	 * Fetch all live births data.
	 * 
	 * @return the live births data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth
	 *         LiveBirth} objects
	 * 
	 * @see PopulationStatisticsClient#getLiveBirths(Collection, Collection, Collection, Collection)
	 */
	public List<LiveBirth> getLiveBirths() {
		return this.getLiveBirths(null, null, null, null);
	}

	/**
	 * Fetch all live births data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param motherAges
	 *            the mothers' ages to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the live births data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth
	 *         LiveBirth} objects
	 */
	public List<LiveBirth> getLiveBirths(Collection<String> regions, Collection<String> motherAges,
			Collection<Integer> genders, Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", ListUtility.toList("BE0101E2"));
		mappings.put("Region", regions);
		mappings.put("AlderModer", motherAges);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101H/FoddaK", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, LiveBirth.class);
	}

	/**
	 * Fetch all population data data.
	 * 
	 * @return the population data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.Population
	 *         Population} objects
	 * 
	 * @see PopulationStatisticsClient#getPopulation(Collection, Collection, Collection, Collection,
	 *      Collection)
	 */
	public List<Population> getPopulation() {
		return this.getPopulation(null, null, null, null, null);
	}

	/**
	 * Fetch all population data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param relationshipStatuses
	 *            the relationship statuses to fetch data for
	 * @param ages
	 *            the ages to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the population data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.Population
	 *         Population} objects
	 */
	public List<Population> getPopulation(Collection<String> regions, Collection<String> relationshipStatuses,
			Collection<String> ages, Collection<Integer> genders, Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", Arrays.asList("BE0101N1", "BE0101N2"));
		mappings.put("Region", regions);
		mappings.put("Civilstand", relationshipStatuses);
		mappings.put("Alder", ages);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101A/BefolkningNy", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, Population.class);
	}

}
<commit_msg>Removed multiple contents code (to be done last)<commit_after>/*
 * Copyright 2014 <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 com.github.dannil.scbjavaclient.client.population.statistic;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.github.dannil.scbjavaclient.client.AbstractClient;
import com.github.dannil.scbjavaclient.model.population.statistic.AverageAge;
import com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth;
import com.github.dannil.scbjavaclient.model.population.statistic.Population;
import com.github.dannil.scbjavaclient.utility.JsonUtility;
import com.github.dannil.scbjavaclient.utility.ListUtility;
import com.github.dannil.scbjavaclient.utility.QueryBuilder;

/**
 * Client which handles population statistics data fetching.
 * 
 * @author <NAME>
 */
public class PopulationStatisticsClient extends AbstractClient {

	/**
	 * Default constructor.
	 */
	public PopulationStatisticsClient() {
		super();
	}

	/**
	 * Overloaded constructor.
	 * 
	 * @param locale
	 *            the locale for this client
	 */
	public PopulationStatisticsClient(Locale locale) {
		super(locale);
	}

	// public List<String> getRegions() {
	// return super.getRegions(getUrl());
	// }

	// public List<Integer> getYears() {
	// List<String> fetchedYears = super.getYears(getUrl());
	//
	// List<Integer> years = new ArrayList<Integer>(fetchedYears.size());
	// for (String fetchedYear : fetchedYears) {
	// years.add(Integer.valueOf(fetchedYear));
	// }
	// return years;
	// }

	/**
	 * Fetch all average age data.
	 * 
	 * @return the average age data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.AverageAge
	 *         AverageAge} objects
	 * 
	 * @see PopulationStatisticsClient#getAverageAge(Collection, Collection, Collection)
	 */
	public List<AverageAge> getAverageAge() {
		return this.getAverageAge(null, null, null);
	}

	/**
	 * Fetch all average age data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the average age data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.AverageAge
	 *         AverageAge} objects
	 */
	public List<AverageAge> getAverageAge(Collection<String> regions, Collection<String> genders,
			Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", ListUtility.toList("BE0101G9"));
		mappings.put("Region", regions);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101B/BefolkningMedelAlder", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, AverageAge.class);
	}

	/**
	 * Fetch all live births data.
	 * 
	 * @return the live births data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth
	 *         LiveBirth} objects
	 * 
	 * @see PopulationStatisticsClient#getLiveBirths(Collection, Collection, Collection, Collection)
	 */
	public List<LiveBirth> getLiveBirths() {
		return this.getLiveBirths(null, null, null, null);
	}

	/**
	 * Fetch all live births data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param motherAges
	 *            the mothers' ages to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the live births data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.LiveBirth
	 *         LiveBirth} objects
	 */
	public List<LiveBirth> getLiveBirths(Collection<String> regions, Collection<String> motherAges,
			Collection<Integer> genders, Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", ListUtility.toList("BE0101E2"));
		mappings.put("Region", regions);
		mappings.put("AlderModer", motherAges);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101H/FoddaK", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, LiveBirth.class);
	}

	/**
	 * Fetch all population data data.
	 * 
	 * @return the population data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.Population
	 *         Population} objects
	 * 
	 * @see PopulationStatisticsClient#getPopulation(Collection, Collection, Collection, Collection,
	 *      Collection)
	 */
	public List<Population> getPopulation() {
		return this.getPopulation(null, null, null, null, null);
	}

	/**
	 * Fetch all population data which match the input constraints.
	 * 
	 * @param regions
	 *            the regions to fetch data for
	 * @param relationshipStatuses
	 *            the relationship statuses to fetch data for
	 * @param ages
	 *            the ages to fetch data for
	 * @param genders
	 *            the genders to fetch data for
	 * @param years
	 *            the years to fetch data for
	 * 
	 * @return the population data wrapped in a list of
	 *         {@link com.github.dannil.scbjavaclient.model.population.statistic.Population
	 *         Population} objects
	 */
	public List<Population> getPopulation(Collection<String> regions, Collection<String> relationshipStatuses,
			Collection<String> ages, Collection<Integer> genders, Collection<Integer> years) {
		Map<String, Collection<?>> mappings = new HashMap<String, Collection<?>>();
		mappings.put("ContentsCode", Arrays.asList("BE0101N1"));
		mappings.put("Region", regions);
		mappings.put("Civilstand", relationshipStatuses);
		mappings.put("Alder", ages);
		mappings.put("Kon", genders);
		mappings.put("Tid", years);

		String response = super.post("BE/BE0101/BE0101A/BefolkningNy", QueryBuilder.build(mappings));

		return JsonUtility.jsonToListOf(response, Population.class);
	}

}

{'fraction_non_alphanumeric': 0.11181357053591119, 'fraction_numerical': 0.0072778063662427405, 'mean_word_length': 3.6926526388409795, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, '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': '2775883', 'n_tokens_mistral': 4388, 'n_tokens_neox': 3935, 'n_words': 1060}