summaryrefslogtreecommitdiff
path: root/src/main/java/com/stileeducation/markr/dto/SummaryMarksDTO.java
blob: 788eea073d502aa582c5fb421f3fb5db78a109f4 (plain)
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
package com.stileeducation.markr.dto;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;

import java.util.Objects;

@XmlRootElement(name = "summary-marks")
public class SummaryMarksDTO {

  @NotNull(message = "Available marks must not be null")
  @Min(value = 0, message = "Available marks must be non-negative")
  private Integer available;

  @NotNull(message = "Obtained marks must not be null")
  @Min(value = 0, message = "Obtained marks must be non-negative")
  private Integer obtained;

  @XmlAttribute(name = "available")
  public int getAvailable() {
    return available;
  }

  public void setAvailable(int available) {
    this.available = available;
  }

  @XmlAttribute(name = "obtained")
  public int getObtained() {
    return obtained;
  }

  public void setObtained(int obtained) {
    this.obtained = obtained;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    SummaryMarksDTO that = (SummaryMarksDTO) o;
    return available == that.available && obtained == that.obtained;
  }

  @Override
  public int hashCode() {
    return Objects.hash(available, obtained);
  }

  @Override
  public String toString() {
    return "SummaryMarksDTO{" +
        "available=" + available +
        ", obtained=" + obtained +
        '}';
  }
}