package org.raddatz.familienarchiv.geschichte;

/**
 * Utility for joining a person's first and last name into a display string.
 * Centralises the logic that was previously duplicated across GeschichteService
 * and JourneyItemService.
 */
public class PersonNameFormatter {

    private PersonNameFormatter() {
        // utility class — no instances
    }

    public static String join(String firstName, String lastName) {
        String first = firstName != null ? firstName.trim() : "";
        String last = lastName != null ? lastName.trim() : "";
        if (first.isEmpty() && last.isEmpty()) return "";
        if (first.isEmpty()) return last;
        if (last.isEmpty()) return first;
        return first + " " + last;
    }
}
