package at.procon.eventhub.reference;

public final class DriverCardNumberNormalizer {

    public static final int CANONICAL_LENGTH = 14;

    private DriverCardNumberNormalizer() {
    }

    public static String canonical(String rawCardNumber) {
        String normalized = normalize(rawCardNumber);
        if (normalized == null) {
            return null;
        }
        return normalized.length() <= CANONICAL_LENGTH
                ? normalized
                : normalized.substring(0, CANONICAL_LENGTH);
    }

    public static String full(String rawCardNumber) {
        return normalize(rawCardNumber);
    }

    private static String normalize(String value) {
        if (value == null || value.isBlank()) {
            return null;
        }
        return value.trim().toUpperCase();
    }
}
