-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParkingLot.java
128 lines (105 loc) · 2.72 KB
/
ParkingLot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.deange.uwaterlooapi.model.parking;
import android.os.Parcel;
import android.os.Parcelable;
import com.deange.uwaterlooapi.model.BaseModel;
import com.deange.uwaterlooapi.utils.DateUtils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
public class ParkingLot
extends BaseModel
implements
Parcelable {
@SerializedName("lot_name")
String mLotName;
@SerializedName("latitude")
float mLatitude;
@SerializedName("longitude")
float mLongitude;
@SerializedName("capacity")
int mCapacity;
@SerializedName("current_count")
int mCurrentCount;
@SerializedName("percent_filled")
int mPercentFilled;
@SerializedName("last_updated")
String mLastUpdated;
protected ParkingLot(final Parcel in) {
super(in);
mLotName = in.readString();
mLatitude = in.readFloat();
mLongitude = in.readFloat();
mCapacity = in.readInt();
mCurrentCount = in.readInt();
mPercentFilled = in.readInt();
mLastUpdated = in.readString();
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
super.writeToParcel(dest, flags);
dest.writeString(mLotName);
dest.writeFloat(mLatitude);
dest.writeFloat(mLongitude);
dest.writeInt(mCapacity);
dest.writeInt(mCurrentCount);
dest.writeInt(mPercentFilled);
dest.writeString(mLastUpdated);
}
public static final Creator<ParkingLot> CREATOR = new Creator<ParkingLot>() {
@Override
public ParkingLot createFromParcel(final Parcel in) {
return new ParkingLot(in);
}
@Override
public ParkingLot[] newArray(final int size) {
return new ParkingLot[size];
}
};
/**
* Name of the parking lot
*/
public String getLotName() {
return mLotName;
}
/**
* Location [latitude, longitude] coordinates
*/
public float[] getLocation() {
return new float[]{mLatitude, mLongitude};
}
/**
* Capacity of the parking lot
*/
public int getCapacity() {
return mCapacity;
}
/**
* Current count of the number of cars in the parking lot
*/
public int getCurrentCount() {
return mCurrentCount;
}
/**
* Percentage of which the parking lot is filled, rounded to the nearest integer
*/
public int getPercentFilledRounded() {
return mPercentFilled;
}
/**
* Percentage of which the parking lot is filled
*/
public float getPercentFilled() {
return (float) mCurrentCount / (float) mCapacity;
}
/**
* Time which the `current_count` was last updated
*/
public Date getLastUpdated() {
return DateUtils.parseDate(mLastUpdated);
}
/**
* Time which the `current_count` was last updated as a string
*/
public String getLastUpdatedRaw() {
return mLastUpdated;
}
}