package hr.com.port.ips.eracun.modeli;

public enum PosrednikType {

    UNKNOWN(-1, "UNKNOWN", "Nepoznat"),
    MER(0, "MER", "Elektronički računi d.o.o.");

    private final int id;
    private final String code;
    private final String naziv;

    PosrednikType(int id, String code, String naziv) {
        this.id = id;
        this.code = code;
        this.naziv = naziv;
    }

    public int getId() {
        return id;
    }

    public String getCode() {
        return code;
    }

    public String getNaziv() {
        return naziv;
    }

    public static PosrednikType fromId(int id) {
        for (PosrednikType p : values()) {
            if (p.id == id) {
                return p;
            }
        }
        return UNKNOWN;
    }

    public static PosrednikType fromCode(String code) {
        if (code != null) {
            for (PosrednikType p : values()) {
                if (p.code.equalsIgnoreCase(code)) {
                    return p;
                }
            }
        }
        return UNKNOWN;
    }
}