HorseDto.java 3.48 KB
Newer Older
1 2
package at.ac.tuwien.sepm.assignment.individual.endpoint.dto;

3 4
import at.ac.tuwien.sepm.assignment.individual.enums.ERace;

5 6 7 8 9 10 11 12 13 14
import java.time.LocalDateTime;
import java.util.Objects;
import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class HorseDto extends BaseDto {
    private String name;
    private String description;
    private short score;
15
    private ERace race;
16
    private Date birthday;
17
    private String imagePath;
18
    private Long owner;
19 20 21

    public HorseDto() {}

22
    public HorseDto(String name, String description, short score, Date birthday, ERace race, String imagePath, Long owner) {
23 24 25 26
        this.name = name;
        this.description = description;
        this.score = score;
        this.birthday = birthday;
27
        this.race = race;
28
        this.imagePath = imagePath;
29 30 31
        this.owner = owner;
    }

32
    public HorseDto(Long id, String name, String description, short score, Date birthday, ERace race, String imagePath, LocalDateTime created, LocalDateTime updated, Long owner) {
33 34 35 36 37
        super(id, created, updated);
        this.name = name;
        this.description = description;
        this.score = score;
        this.birthday = birthday;
38
        this.race = race;
39
        this.imagePath = imagePath;
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
        this.owner = owner;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public short getScore() {
        return score;
    }

    public void setScore(short score) {
        this.score = score;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

75 76 77 78 79 80 81 82
    public ERace getRace() {
        return race;
    }

    public void setRace(ERace race) {
        this.race = race;
    }

83 84 85 86 87 88 89 90
    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

91 92 93 94 95 96 97 98 99 100 101 102 103
    public Long getOwner() {
        return owner;
    }

    public void setOwner(Long owner) {
        this.owner = owner;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof HorseDto)) return false;
        if (!super.equals(o)) return false;
104 105 106 107 108 109
        HorseDto h = (HorseDto) o;
        return Objects.equals(name, h.name) &&
            Objects.equals(description, h.description) &&
            Objects.equals(score, h.score) &&
            Objects.equals(birthday, h.birthday) &&
            Objects.equals(race, h.race) &&
110
            Objects.equals(imagePath, h.imagePath) &&
111
            Objects.equals(owner, h.owner);
112 113 114 115 116 117 118 119 120 121 122 123
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), name);
    }

    @Override
    protected String fieldsString() {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        return super.fieldsString() + ", name='" + name + '\'' +
124 125 126
            ", description='" + description + '\'' +
            ", score='" + score + '\'' +
            ", birthday='" + df.format(birthday) + '\'' +
127
            ", race='" + race + '\'' +
128
            ", imagePath='" + imagePath + '\'' +
129
            ", owner_id='" + owner + '\'';
130 131 132 133 134 135 136
    }

    @Override
    public String toString() {
        return "HorseDto{ " + fieldsString() + " }";
    }
}