<commit_before>package ch.rasc.s4ws.grid;

import java.io.IOException;
import java.util.Collection;

import org.springframework.expression.ParseException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Ordering;

public class PropertyOrderingFactory {

	private final static ObjectMapper mapper = new ObjectMapper();

	private PropertyOrderingFactory() {
		// singleton
	}

	public static <T> Ordering<T> createOrdering(String propertyName) {
		try {
			Ordering<T> ordering = new PropertyOrdering<>(propertyName);
			return ordering;
		} catch (ParseException e) {
			return null;
		}
	}

	public static <T> Ordering<T> createOrdering(String propertyName, SortDirection sortDirection) {
		try {
			Ordering<T> ordering = new PropertyOrdering<>(propertyName);

			if (sortDirection == SortDirection.DESC) {
				ordering = ordering.reverse();
			}

			return ordering;
		} catch (ParseException e) {
			return null;
		}
	}

	public static <T> Ordering<T> createOrderingFromSorters(String sortInfo) throws JsonParseException,
			JsonMappingException, IOException {
		if (sortInfo == null) {
			return null;
		}

		Collection<SortInfo> sortInfos = mapper.readValue(sortInfo, new TypeReference<Collection<SortInfo>>() {
		});

		Ordering<T> ordering = null;

		if (sortInfos != null) {
			for (SortInfo sorter : sortInfos) {
				Ordering<T> propertyOrdering = createOrdering(sorter.getProperty(), sorter.getDirection());
				if (ordering == null) {
					ordering = propertyOrdering;
				} else {
					ordering = ordering.compound(propertyOrdering);
				}
			}
		}

		return ordering;<commit_msg>Remove warning in eclipse<commit_after>package ch.rasc.s4ws.grid;

import java.io.IOException;
import java.util.Collection;

import org.springframework.expression.ParseException;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Ordering;

public class PropertyOrderingFactory {

	private final static ObjectMapper mapper = new ObjectMapper();

	private PropertyOrderingFactory() {
		// singleton
	}

	public static <T> Ordering<T> createOrdering(String propertyName) {
		try {
			Ordering<T> ordering = new PropertyOrdering<>(propertyName);
			return ordering;
		} catch (ParseException e) {
			return null;
		}
	}

	public static <T> Ordering<T> createOrdering(String propertyName, SortDirection sortDirection) {
		try {
			Ordering<T> ordering = new PropertyOrdering<>(propertyName);

			if (sortDirection == SortDirection.DESC) {
				ordering = ordering.reverse();
			}

			return ordering;
		} catch (ParseException e) {
			return null;
		}
	}

	public static <T> Ordering<T> createOrderingFromSorters(String sortInfo) throws JsonParseException,
			JsonMappingException, IOException {
		if (sortInfo == null) {
			return null;
		}

		Collection<SortInfo> sortInfos = mapper.readValue(sortInfo, new TypeReference<Collection<SortInfo>>() {
			//nothing here
		});

		Ordering<T> ordering = null;

		if (sortInfos != null) {
			for (SortInfo sorter : sortInfos) {
				Ordering<T> propertyOrdering = createOrdering(sorter.getProperty(), sorter.getDirection());
				if (ordering == null) {
					ordering = propertyOrdering;
				} else {
					ordering = ordering.compound(propertyOrdering);
				}
			}
		}

		return ordering;
{'fraction_non_alphanumeric': 0.10590182018753447, 'fraction_numerical': 0.0005515719801434088, 'mean_word_length': 4.571428571428571, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '7658457', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1057, 'n_words': 240}