/*
 *  Copyright (c) 2025 John Ahlroos / Devsoap
 *
 *  Creative Commons Attribution-NoDerivatives 4.0 International Public License
 *
 *  By exercising the Licensed Rights (defined below), You accept and agree
 *  to be bound by the terms and conditions of this Creative Commons
 *  Attribution-NoDerivatives 4.0 International Public License ("Public
 *  License"). To the extent this Public License may be interpreted as a
 *  contract, You are granted the Licensed Rights in consideration of Your
 *  acceptance of these terms and conditions, and the Licensor grants You
 *  such rights in consideration of benefits the Licensor receives from
 *  making the Licensed Material available under these terms and
 *  conditions.
 *
 *  Refer to LICENSE file or https://creativecommons.org/licenses/by-nd/4.0 for full license.
 *
 */

package com.devsoap.tincheck.tin;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.micronaut.serde.annotation.Serdeable;
import lombok.RequiredArgsConstructor;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.Random;

public interface TinGenerator {

    String generate(LocalDate yearOfBirth, Gender gender, Random randomGenerator);

    @Serdeable
    enum Gender {
        MALE ("m"),
        FEMALE ("f");

        Gender(String symbol) {
            this.symbol = symbol;
        }

        @JsonValue
        private final String symbol;

        @JsonCreator
        public static Gender fromSymbol(String symbol) {
            return Arrays.stream(values()).filter(g -> g.symbol.equals(symbol)).findFirst().orElse(null);
        }
    }
}