package de.sebse.fuplanner.services.KVV.types;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Lecturer implements Serializable {
    private final String firstname;
    private final String surname;
    private final String mail;

    public Lecturer(String parsableString) throws NoSuchFieldException {
        Pattern pattern = Pattern.compile("([^|]*)\\|([^|]*)\\|([^|]*)\\|\\|", Pattern.DOTALL);
        Matcher matcher = pattern.matcher(parsableString);
        if (!matcher.find()) {
            throw new NoSuchFieldException();
        }
        this.firstname = matcher.group(1);
        this.surname = matcher.group(2);
        this.mail = matcher.group(3);
    }

    public String getFirstname() {
        return firstname;
    }

    public String getSurname() {
        return surname;
    }

    public String getMail() {
        return mail;
    }

    @Override
    public String toString() {
        return "First name: "+getFirstname()+
                "\nSurname: "+getSurname()+
                "\nMail: "+getMail();
    }
}
