1 package org.oxerr.viagogo.model;
2
3 import java.io.Serializable;
4
5 import org.apache.commons.lang3.builder.CompareToBuilder;
6 import org.apache.commons.lang3.builder.EqualsBuilder;
7 import org.apache.commons.lang3.builder.HashCodeBuilder;
8 import org.apache.commons.lang3.math.NumberUtils;
9
10
11
12
13
14
15 public class Seating implements Comparable<Seating>, Serializable {
16
17 private static final long serialVersionUID = 2023021301L;
18
19
20
21
22 private String section;
23
24
25
26
27 private String row;
28
29
30
31
32 private String seatFrom;
33
34
35
36
37 private String seatTo;
38
39 public Seating() {
40 }
41
42 public Seating(String section, String row, String seatFrom, String seatTo) {
43 this.section = section;
44 this.row = row;
45 this.seatFrom = seatFrom;
46 this.seatTo = seatTo;
47 }
48
49 public String getSection() {
50 return section;
51 }
52
53 public void setSection(String section) {
54 this.section = section;
55 }
56
57 public String getRow() {
58 return row;
59 }
60
61 public void setRow(String row) {
62 this.row = row;
63 }
64
65 public String getSeatFrom() {
66 return seatFrom;
67 }
68
69 public void setSeatFrom(String seatFrom) {
70 this.seatFrom = seatFrom;
71 }
72
73 public String getSeatTo() {
74 return seatTo;
75 }
76
77 public void setSeatTo(String seatTo) {
78 this.seatTo = seatTo;
79 }
80
81 @Override
82 public int hashCode() {
83 return HashCodeBuilder.reflectionHashCode(this);
84 }
85
86 @Override
87 public boolean equals(Object obj) {
88 if (obj == null) {
89 return false;
90 }
91 if (obj == this) {
92 return true;
93 }
94 if (obj.getClass() != getClass()) {
95 return false;
96 }
97 Seating rhs = (Seating) obj;
98 return EqualsBuilder.reflectionEquals(this, rhs);
99 }
100
101 @Override
102 public String toString() {
103 return String.format("%s | Row %s | Seat %s-%s",
104 this.section.trim(),
105 this.row.trim(),
106 this.seatFrom.trim(),
107 this.seatTo.trim()
108 );
109 }
110
111 @Override
112 public int compareTo(Seating o) {
113 return new CompareToBuilder()
114 .append(this.section, o.section)
115 .append(this.row, o.row)
116 .append(NumberUtils.toInt(this.seatFrom), NumberUtils.toInt(o.seatFrom))
117 .append(NumberUtils.toInt(this.seatTo), NumberUtils.toInt(o.seatTo))
118 .toComparison();
119 }
120
121 }