1 package myorg.relex.collection;
2
3 import javax.persistence.*;
4
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7
8
9
10 @Entity
11 @Table(name="RELATIONEX_SEGMENT")
12 public class Segment implements Comparable<Segment>{
13 private static final Logger log = LoggerFactory.getLogger(Segment.class);
14 @Id @GeneratedValue
15 private int id;
16
17 private int number;
18
19 @Column(name="TO", length=16)
20 private String to;
21 @Column(name="FM", length=16)
22 private String from;
23
24
25 public int getId() { return id; }
26
27 public int getNumber() { return number; }
28 public Segment setNumber(int number) {
29 this.number = number;
30 return this;
31 }
32
33 public String getTo() { return to; }
34 public Segment setTo(String to) {
35 this.to = to;
36 return this;
37 }
38
39 public String getFrom() { return from; }
40 public Segment setFrom(String from) {
41 this.from = from;
42 return this;
43 }
44
45 @Override
46 public int compareTo(Segment rhs) {
47 if (this == rhs) { return 0; }
48 int result = number - rhs.number;
49 log.debug(getClass().getSimpleName() + toString() +
50 ".compareTo" + rhs.toString() +
51 "=" + result
52 );
53 return result;
54 }
55
56 @Override
57 public String toString() {
58 return "(id=" + id + ",number=" + number + ")";
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 }