Изменение в иерархии контента

This commit is contained in:
Mark Struchkov 2019-05-18 13:10:25 +03:00
parent af4d2c1c59
commit f46890edae
2 changed files with 15 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import java.util.Objects;
public abstract class Content { public abstract class Content {
private Integer personId; private Integer personId;
private String message;
public Content() { public Content() {
@ -12,6 +13,7 @@ public abstract class Content {
public Content(Content source) { public Content(Content source) {
this.personId = source.getPersonId(); this.personId = source.getPersonId();
this.message = source.getMessage();
} }
public Integer getPersonId() { public Integer getPersonId() {
@ -22,16 +24,25 @@ public abstract class Content {
this.personId = personId; this.personId = personId;
} }
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (!(o instanceof Content)) return false; if (!(o instanceof Content)) return false;
Content content = (Content) o; Content content = (Content) o;
return Objects.equals(personId, content.personId); return Objects.equals(personId, content.personId) &&
Objects.equals(message, content.message);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(personId); return Objects.hash(personId, message);
} }
} }

View File

@ -10,7 +10,6 @@ public class Mail extends Content {
private Integer id; private Integer id;
private LocalDateTime date; private LocalDateTime date;
private String message;
private List<Attachment> attachments; private List<Attachment> attachments;
public Mail() { public Mail() {
@ -21,7 +20,6 @@ public class Mail extends Content {
super(source); super(source);
this.id = source.getId(); this.id = source.getId();
this.date = source.getDate(); this.date = source.getDate();
this.message = source.getMessage();
} }
public Integer getId() { public Integer getId() {
@ -41,14 +39,6 @@ public class Mail extends Content {
} }
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Mail prototype() { public Mail prototype() {
return new Mail(this); return new Mail(this);
} }
@ -69,12 +59,12 @@ public class Mail extends Content {
Mail mail = (Mail) o; Mail mail = (Mail) o;
return Objects.equals(id, mail.id) && return Objects.equals(id, mail.id) &&
Objects.equals(date, mail.date) && Objects.equals(date, mail.date) &&
Objects.equals(message, mail.message); Objects.equals(attachments, mail.attachments);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(super.hashCode(), id, date, message); return Objects.hash(super.hashCode(), id, date, attachments);
} }
@Override @Override
@ -82,7 +72,6 @@ public class Mail extends Content {
return "Mail{" + return "Mail{" +
"id=" + id + "id=" + id +
", date=" + date + ", date=" + date +
", message='" + message + '\'' +
", attachments=" + attachments + ", attachments=" + attachments +
'}'; '}';
} }