View Javadoc
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   * Represents the seating information for a ticket(s) in a Venue.
12   *
13   * <a href="https://developer.viagogo.net/api-reference/inventory#tag/BasicType_Seating">Seating</a>
14   */
15  public class Seating implements Comparable<Seating>, Serializable {
16  
17  	private static final long serialVersionUID = 2023021301L;
18  
19  	/**
20  	 * The section of the ticket(s).
21  	 */
22  	private String section;
23  
24  	/**
25  	 * The row of the ticket(s).
26  	 */
27  	private String row;
28  
29  	/**
30  	 * The first in a contiguous block of seats to which the tickets have been allocated.
31  	 */
32  	private String seatFrom;
33  
34  	/**
35  	 * The last in a contiguous block of seats to which the tickets have been allocated.
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 (this == obj) {
89  			return true;
90  		}
91  		if (!(obj instanceof Seating)) {
92  			return false;
93  		}
94  		Seating rhs = (Seating) obj;
95  		return EqualsBuilder.reflectionEquals(this, rhs);
96  	}
97  
98  	@Override
99  	public String toString() {
100 		return String.format("%s | Row %s | Seat %s-%s",
101 			this.section.trim(),
102 			this.row.trim(),
103 			this.seatFrom.trim(),
104 			this.seatTo.trim()
105 		);
106 	}
107 
108 	@Override
109 	public int compareTo(Seating o) {
110 		return new CompareToBuilder()
111 			.append(this.section, o.section)
112 			.append(this.row, o.row)
113 			.append(NumberUtils.toInt(this.seatFrom), NumberUtils.toInt(o.seatFrom))
114 			.append(NumberUtils.toInt(this.seatTo), NumberUtils.toInt(o.seatTo))
115 			.toComparison();
116 	}
117 
118 }