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);
    }

    private String getFirstName() {
        return firstName;
    }

    private String getSurname() {
        return surname;
    }

    private String getMail() {
        return mail;
    }

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