What is the problem
Suppose we have models like this:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17class Student {
private Teacher teacher;
public Teacher getTeacher() { return teacher; }
public void setTeacher(Teacher teacher) { this.teacher = teacher; }
}
class Teacher {
private Email email;
public Email getEmail() { return email; }
public void setEmail(Email email) { this.email = email; }
}
class Email {
private String address;
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
}
(Not domain model actually, just poor data container. I’ll come back to this topic later.)
Now given a student instance, I need to do some change to the teacher’s email. How can I do? Firstly I need a way to retrieve the mail address.