HorseDto.java 2.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
package at.ac.tuwien.sepm.assignment.individual.endpoint.dto;

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;
    private Date birthday;
    private long owner;

    public HorseDto() {}

    public HorseDto(String name, String description, short score, Date birthday, Long owner) {
        this.name = name;
        this.description = description;
        this.score = score;
        this.birthday = birthday;
        this.owner = owner;
    }

    public HorseDto(Long id, String name, String description, short score, Date birthday, LocalDateTime created, LocalDateTime updated, Long owner) {
        super(id, created, updated);
        this.name = name;
        this.description = description;
        this.score = score;
        this.birthday = birthday;
        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;
    }

    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;
        HorseDto horseDto = (HorseDto) o;
        return Objects.equals(name, horseDto.name);
    }

    @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 + '\'' +
            "description='" + description + '\'' +
            "score='" + score + '\'' +
            "birthday='" + df.format(birthday) + '\'' +
            "owner_id='" + owner + '\'';
    }

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