<commit_before>package ch.elexis.core.model.format;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.apache.commons.lang3.StringUtils;

import ch.elexis.core.l10n.Messages;
import ch.elexis.core.model.IPerson;
import ch.elexis.core.types.Gender;

public class PersonFormatUtil {
	
	private static DateTimeFormatter defaultDateFormatter =
		DateTimeFormatter.ofPattern("dd.MM.yyyy");
	
	/**
	 * Get the date of birth of the person in the default date format (Ger. dd.MM.yyyy).
	 * 
	 * @param person
	 * @return
	 */
	public static String getDateOfBirth(IPerson person){
		LocalDateTime dob = person.getDateOfBirth();
		if (dob != null) {
			return dob.format(defaultDateFormatter);
		}
		return "";
	}
	
	/**
	 * Get the gender of the person as localized char.
	 * 
	 * @param person
	 * @return
	 */
	public static char getGenderCharLocalized(IPerson person){
		Gender gender = person.getGender();
		if (gender != null) {
			if (Gender.MALE == gender) {
				return 'm';
			}
			if (Gender.FEMALE == gender) {
				return 'w';
			}
		}
		return '?';
	}
	
	/**
	 * Get the personalia text for a person. </br>
	 * If the person has a title it is appended to the end of the text, for name searches.
	 * 
	 * @param person
	 * @return
	 */
	public static String getPersonalia(IPerson person){
		StringBuilder sb = new StringBuilder(64);
		
		if (StringUtils.isNoneEmpty(person.getLastName())) {
			sb.append(person.getLastName());
		}
		if (StringUtils.isNotBlank(sb.toString())) {
			sb.append(" ");
		}
		if (StringUtils.isNoneEmpty(person.getFirstName())) {
			sb.append(person.getFirstName());
		}
		
		if (getGenderCharLocalized(person) != '?') {
			sb.append(" (").append(getGenderCharLocalized(person)).append("), ");
		}
		
		String dob = getDateOfBirth(person);
		if (StringUtils.isNoneEmpty(dob)) {
			sb.append(dob);
		}
		
		if (StringUtils.isNoneEmpty(person.getTitel())) {
			sb.append(",").append(person.getTitel());
		}
		return sb.toString();
	}
	
	public static String getSalutation(IPerson person){
		if (person.getGender().equals(Gender.MALE)) {
			return Messages.KontakteView_SalutationM;
		} else if (person.getGender().equals(Gender.FEMALE)) {
			return Messages.KontakteView_SalutationF;
		} else {
			return ""; //$NON-NLS-1$
		}
	}
}<commit_msg>[22665] add method to get full name only to PersonFormatUtil<commit_after>package ch.elexis.core.model.format;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.apache.commons.lang3.StringUtils;

import ch.elexis.core.l10n.Messages;
import ch.elexis.core.model.IPerson;
import ch.elexis.core.types.Gender;

public class PersonFormatUtil {
	
	private static DateTimeFormatter defaultDateFormatter =
		DateTimeFormatter.ofPattern("dd.MM.yyyy");
	
	/**
	 * Get the date of birth of the person in the default date format (Ger. dd.MM.yyyy).
	 * 
	 * @param person
	 * @return
	 */
	public static String getDateOfBirth(IPerson person){
		LocalDateTime dob = person.getDateOfBirth();
		if (dob != null) {
			return dob.format(defaultDateFormatter);
		}
		return "";
	}
	
	/**
	 * Get the gender of the person as localized char.
	 * 
	 * @param person
	 * @return
	 */
	public static char getGenderCharLocalized(IPerson person){
		Gender gender = person.getGender();
		if (gender != null) {
			if (Gender.MALE == gender) {
				return 'm';
			}
			if (Gender.FEMALE == gender) {
				return 'w';
			}
		}
		return '?';
	}
	
	/**
	 * Get the personalia text for a person. </br>
	 * If the person has a title it is appended to the end of the text, for name searches.
	 * 
	 * @param person
	 * @return
	 */
	public static String getPersonalia(IPerson person){
		StringBuilder sb = new StringBuilder(64);
		
		if (StringUtils.isNoneEmpty(person.getLastName())) {
			sb.append(person.getLastName());
		}
		if (StringUtils.isNotBlank(sb.toString())) {
			sb.append(" ");
		}
		if (StringUtils.isNoneEmpty(person.getFirstName())) {
			sb.append(person.getFirstName());
		}
		
		if (getGenderCharLocalized(person) != '?') {
			sb.append(" (").append(getGenderCharLocalized(person)).append("), ");
		}
		
		String dob = getDateOfBirth(person);
		if (StringUtils.isNoneEmpty(dob)) {
			sb.append(dob);
		}
		
		if (StringUtils.isNoneEmpty(person.getTitel())) {
			sb.append(",").append(person.getTitel());
		}
		return sb.toString();
	}
	
	public static String getFullName(IPerson person){
		StringBuilder sb = new StringBuilder(64);
		
		if (StringUtils.isNoneEmpty(person.getTitel())) {
			sb.append(person.getTitel());
		}
		if (StringUtils.isNotBlank(sb.toString())) {
			sb.append(" ");
		}
		if (StringUtils.isNoneEmpty(person.getLastName())) {
			sb.append(person.getLastName());
		}
		if (StringUtils.isNotBlank(sb.toString())) {
			sb.append(" ");
		}
		if (StringUtils.isNoneEmpty(person.getFirstName())) {
			sb.append(person.getFirstName());
		}
		return sb.toString();
	}
	
	public static String getSalutation(IPerson person){
		if (person.getGender().equals(Gender.MALE)) {
			return Messages.KontakteView_SalutationM;
		} else if (person.getGender().equals(Gender.FEMALE)) {
			return Messages.KontakteView_SalutationF;
		} else {
			return ""; //$NON-NLS-1$
		}
	}
}
{'fraction_non_alphanumeric': 0.14346072594584214, 'fraction_numerical': 0.003648934127136547, 'mean_word_length': 3.7302452316076296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7153109', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1721, 'n_words': 369}