<commit_before>package ch.openech.model.common;

import org.minimalj.model.InvalidValues;
import org.minimalj.model.annotation.Size;
import org.minimalj.model.validation.Validatable;
import org.minimalj.util.DateUtils;
import org.minimalj.util.StringUtils;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.DateTimeParseException;

public class DatePartiallyKnown implements Validatable {

	@Size(10)
	public String value;
	
	@Override
	public String validate() {
		if (InvalidValues.isInvalid(value)) {
			return "Kein gültiges Datum";
		} else {
			return null;
		}
	}

	public LocalDate toLocalDate() {
		if (!StringUtils.isEmpty(value)) {
			try {
				return LocalDate.parse(value, DateTimeFormatter.ISO_DATE);
			} catch (DateTimeParseException x) {
				// silent
				return null;
			}
		} else {
			return null;
		}
	}
	
	public String toString() {
		return DateUtils.format(value);
	}
}
<commit_msg>DatePartiallyKnown: Comparable implementieren, damit die Sortierung in der Personensuche korrekt ist<commit_after>package ch.openech.model.common;

import org.minimalj.model.InvalidValues;
import org.minimalj.model.annotation.Size;
import org.minimalj.model.validation.Validatable;
import org.minimalj.util.DateUtils;
import org.minimalj.util.StringUtils;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.DateTimeParseException;

public class DatePartiallyKnown implements Validatable, Comparable<DatePartiallyKnown> {

	@Size(10)
	public String value;
	
	@Override
	public String validate() {
		if (InvalidValues.isInvalid(value)) {
			return "Kein gültiges Datum";
		} else {
			return null;
		}
	}

	public LocalDate toLocalDate() {
		if (!StringUtils.isEmpty(value)) {
			try {
				return LocalDate.parse(value, DateTimeFormatter.ISO_DATE);
			} catch (DateTimeParseException x) {
				// silent
				return null;
			}
		} else {
			return null;
		}
	}
	
	public String toString() {
		return DateUtils.format(value);
	}

	@Override
	public int compareTo(DatePartiallyKnown o) {
		if (value == null) {
			return o.value != null ? -1 : 0;
		} else {
			if (o.value == null) return 1;
			return value.compareTo(o.value);
		}
	}
}

{'fraction_non_alphanumeric': 0.10441426146010187, 'fraction_numerical': 0.0029711375212224107, 'mean_word_length': 3.4640151515151514, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1464308', 'n_tokens_mistral': 843, 'n_tokens_neox': 755, 'n_words': 158}