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

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 {
private Integer personId;
private String message;
public Content() {
@ -12,6 +13,7 @@ public abstract class Content {
public Content(Content source) {
this.personId = source.getPersonId();
this.message = source.getMessage();
}
public Integer getPersonId() {
@ -22,16 +24,25 @@ public abstract class Content {
this.personId = personId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Content)) return false;
Content content = (Content) o;
return Objects.equals(personId, content.personId);
return Objects.equals(personId, content.personId) &&
Objects.equals(message, content.message);
}
@Override
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 LocalDateTime date;
private String message;
private List<Attachment> attachments;
public Mail() {
@ -21,7 +20,6 @@ public class Mail extends Content {
super(source);
this.id = source.getId();
this.date = source.getDate();
this.message = source.getMessage();
}
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() {
return new Mail(this);
}
@ -69,12 +59,12 @@ public class Mail extends Content {
Mail mail = (Mail) o;
return Objects.equals(id, mail.id) &&
Objects.equals(date, mail.date) &&
Objects.equals(message, mail.message);
Objects.equals(attachments, mail.attachments);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), id, date, message);
return Objects.hash(super.hashCode(), id, date, attachments);
}
@Override
@ -82,7 +72,6 @@ public class Mail extends Content {
return "Mail{" +
"id=" + id +
", date=" + date +
", message='" + message + '\'' +
", attachments=" + attachments +
'}';
}