package com.softserve.academy.food.model;
import com.softserve.academy.food.entity.Attachment;
public class AttachmentModel {
private Long id;
private String name;
private String path;
public AttachmentModel() {}
public AttachmentModel(Attachment attachment) {
id = attachment.getId();
name = attachment.getName();
path = attachment.getPath();
}
public AttachmentModel(String name, String path) {
this.name = name;
this.path = path;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Attachment toEntity() {
return new Attachment(this);
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AttachmentModel other = (AttachmentModel) obj;
if (id == null)
{
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (name == null)
{
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (path == null)
{
if (other.path != null)
return false;
} else if (!path.equals(other.path))
return false;
return true;
}
}