OSDN Git Service

Merge branch 'release/v4.101.2'
[jindolf/Jindolf.git] / src / main / java / jp / sfjp / jindolf / data / html / VillageRecord.java
1 /*
2  * village record
3  *
4  * License : The MIT License
5  * Copyright(c) 2020 olyutorskii
6  */
7
8 package jp.sfjp.jindolf.data.html;
9
10 import jp.sourceforge.jindolf.corelib.VillageState;
11
12 /**
13  * Village record on HTML.
14  */
15 class VillageRecord implements Comparable<VillageRecord> {
16
17     private final String villageId;
18     private final String fullVillageName;
19     private final VillageState villageStatus;
20
21     private final int villageIdNum;
22
23
24     /**
25      * Constructor.
26      *
27      * @param villageId village id on CGI query
28      * @param fullVillageName full village name
29      * @param villageStatus village status
30      */
31     VillageRecord(String villageId,
32                   String fullVillageName,
33                   VillageState villageStatus ){
34         super();
35
36         this.villageId = villageId;
37         this.fullVillageName = fullVillageName;
38         this.villageStatus = villageStatus;
39
40         this.villageIdNum = Integer.parseInt(villageId);
41
42         return;
43     }
44
45     /**
46      * return village id on CGI query.
47      *
48      * @return village id
49      */
50     String getVillageId(){
51         return this.villageId;
52     }
53
54     /**
55      * return long village name.
56      *
57      * @return long village name
58      */
59     String getFullVillageName(){
60         return this.fullVillageName;
61     }
62
63     /**
64      * return village status.
65      *
66      * @return village status
67      */
68     VillageState getVillageStatus(){
69         return this.villageStatus;
70     }
71
72     /**
73      * {@inheritDoc}
74      *
75      * <p>村IDの自然数順に順序づける。
76      *
77      * @param rec {@inheritDoc}
78      * @return {@inheritDoc}
79      */
80     @Override
81     public int compareTo(VillageRecord rec) {
82         int result = this.villageIdNum - rec.villageIdNum;
83         return result;
84     }
85
86     /**
87      * {@inheritDoc}
88      *
89      * @return {@inheritDoc}
90      */
91     @Override
92     public int hashCode() {
93         return this.villageId.hashCode();
94     }
95
96     /**
97      * {@inheritDoc}
98      *
99      * @param obj {@inheritDoc}
100      * @return {@inheritDoc}
101      */
102     @Override
103     public boolean equals(Object obj) {
104         if(this == obj) return true;
105         if(obj == null) return false;
106
107         if(! (obj instanceof VillageRecord)) return false;
108         VillageRecord other = (VillageRecord) obj;
109
110         return this.villageId.equals(other.villageId);
111     }
112
113 }