aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/Bus.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/Bus.java')
-rw-r--r--src/net/cbaines/suma/Bus.java194
1 files changed, 100 insertions, 94 deletions
diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java
index b36dd89..865384f 100644
--- a/src/net/cbaines/suma/Bus.java
+++ b/src/net/cbaines/suma/Bus.java
@@ -31,100 +31,106 @@ import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "buses")
public class Bus {
- final static String ID_FIELD_NAME = "id";
- final static String ROUTE_FIELD_NAME = "route";
- final static String DIRECTION_FIELD_NAME = "direction";
-
- @DatabaseField(generatedId = true)
- int gid;
-
- /**
- * The identification number of the bus.
- */
- @DatabaseField(canBeNull = true)
- String id;
-
- /**
- * The route the bus is travelling.
- */
- @DatabaseField(canBeNull = false, foreign = true)
- BusRoute route;
-
- /**
- * The direction which the bus is travelling.
- */
- @DatabaseField(canBeNull = true)
- String direction;
-
- /**
- * The destination the bus is travelling towards.
- */
- @DatabaseField(canBeNull = true, foreign = true)
- BusStop destination;
-
- Bus() {
- }
-
- /**
- * Create a bus.
- *
- * @param id
- * The identification number of the bus.
- * @param route
- * The route the bus is travelling.
- * @param dir
- * The direction which the bus is travelling.
- */
- Bus(String id, BusRoute route, String direction) {
- this.id = id;
- this.route = route;
- this.direction = direction;
- }
-
- /**
- * Create a bus.
- *
- * @param id
- * The identification number of the bus.
- * @param route
- * The route the bus is travelling.
- */
- Bus(String id, BusRoute route) {
- this(id, route, null);
- }
-
- public String toString() {
- return String.valueOf(id + " (" + route.code + direction + ")");
- }
-
- String getName() {
- if (direction != null) {
- return route.code + direction;
- } else {
- return route.code;
+ final static String ID_FIELD_NAME = "id";
+ final static String ROUTE_FIELD_NAME = "route";
+ final static String DIRECTION_FIELD_NAME = "direction";
+
+ @DatabaseField(generatedId = true)
+ int gid;
+
+ /**
+ * The identification number of the bus.
+ */
+ @DatabaseField(canBeNull = true)
+ String id;
+
+ /**
+ * The route the bus is travelling.
+ */
+ @DatabaseField(canBeNull = false, foreign = true)
+ BusRoute route;
+
+ /**
+ * The direction which the bus is travelling.
+ */
+ @DatabaseField(canBeNull = true)
+ String direction;
+
+ /**
+ * The destination the bus is travelling towards.
+ */
+ @DatabaseField(canBeNull = true, foreign = true)
+ BusStop destination;
+
+ /**
+ * The destination the bus is travelling towards.
+ */
+ @DatabaseField(canBeNull = true)
+ String destinationString;
+
+ Bus() {
+ }
+
+ /**
+ * Create a bus.
+ *
+ * @param id
+ * The identification number of the bus.
+ * @param route
+ * The route the bus is travelling.
+ * @param dir
+ * The direction which the bus is travelling.
+ */
+ Bus(String id, BusRoute route, String direction) {
+ this.id = id;
+ this.route = route;
+ this.direction = direction;
+ }
+
+ /**
+ * Create a bus.
+ *
+ * @param id
+ * The identification number of the bus.
+ * @param route
+ * The route the bus is travelling.
+ */
+ Bus(String id, BusRoute route) {
+ this(id, route, null);
+ }
+
+ public String toString() {
+ return String.valueOf(id + " (" + route.code + direction + ")");
+ }
+
+ String getName() {
+ if (direction != null) {
+ return route.code + direction;
+ } else {
+ return route.code;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + gid;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Bus other = (Bus) obj;
+ if (id != other.id)
+ return false;
+ return true;
}
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + gid;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Bus other = (Bus) obj;
- if (id != other.id)
- return false;
- return true;
- }
}