|
| 1 | +package com.proxerme.library.connection.messenger.entity.conferenceInfo; |
| 2 | + |
| 3 | +import android.os.Parcel; |
| 4 | +import android.os.Parcelable; |
| 5 | +import android.support.annotation.IntRange; |
| 6 | +import android.support.annotation.NonNull; |
| 7 | + |
| 8 | +import com.afollestad.bridge.annotations.Body; |
| 9 | + |
| 10 | +/** |
| 11 | + * The class that represents the ConferenceInfo Conference entity. |
| 12 | + * This class is different to the {@link com.proxerme.library.connection.messenger.entity.Conference} |
| 13 | + * |
| 14 | + * @author Desnoo |
| 15 | + */ |
| 16 | +public class Conference implements Parcelable { |
| 17 | + |
| 18 | + public static final Creator<Conference> CREATOR = new Creator<Conference>() { |
| 19 | + @Override |
| 20 | + public Conference createFromParcel(Parcel in) { |
| 21 | + return new Conference(in); |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public Conference[] newArray(int size) { |
| 26 | + return new Conference[size]; |
| 27 | + } |
| 28 | + }; |
| 29 | + |
| 30 | + @Body(name = "topic") |
| 31 | + String topic; |
| 32 | + @Body(name = "count") |
| 33 | + int participants; |
| 34 | + @Body(name = "timestampStart") |
| 35 | + long timestampStart; |
| 36 | + @Body(name = "timestampEnd") |
| 37 | + long timestampEnd; |
| 38 | + @Body(name = "leader") |
| 39 | + String leaderId; |
| 40 | + |
| 41 | + /** |
| 42 | + * Private Constructor. |
| 43 | + */ |
| 44 | + Conference() { |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * The Constructor. |
| 49 | + * |
| 50 | + * @param topic The topic. |
| 51 | + * @param participants The participants of this conference. |
| 52 | + * @param timestampStart The timestamp when the conference started. |
| 53 | + * @param timestampEnd The timestamp when the last message of the conference was sent. |
| 54 | + * @param leaderId The user id of the conference leader. |
| 55 | + */ |
| 56 | + public Conference(@NonNull String topic, @IntRange(from = 1) int participants, |
| 57 | + @IntRange(from = 0) long timestampStart, @IntRange(from = 0) long timestampEnd, |
| 58 | + @NonNull String leaderId) { |
| 59 | + this.topic = topic; |
| 60 | + this.participants = participants; |
| 61 | + this.timestampStart = timestampStart; |
| 62 | + this.timestampEnd = timestampEnd; |
| 63 | + this.leaderId = leaderId; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * The Constructor parses the parcel. |
| 68 | + * |
| 69 | + * @param in The parcel to parse. |
| 70 | + */ |
| 71 | + protected Conference(Parcel in) { |
| 72 | + topic = in.readString(); |
| 73 | + participants = in.readInt(); |
| 74 | + timestampStart = in.readLong(); |
| 75 | + timestampEnd = in.readLong(); |
| 76 | + leaderId = in.readString(); |
| 77 | + } |
| 78 | + |
| 79 | + |
| 80 | + @Override |
| 81 | + public int describeContents() { |
| 82 | + return 0; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public void writeToParcel(Parcel parcel, int i) { |
| 87 | + parcel.writeString(topic); |
| 88 | + parcel.writeInt(participants); |
| 89 | + parcel.writeLong(timestampStart); |
| 90 | + parcel.writeLong(timestampEnd); |
| 91 | + parcel.writeString(leaderId); |
| 92 | + } |
| 93 | + |
| 94 | + |
| 95 | + /** |
| 96 | + * Returns the Topic. |
| 97 | + * |
| 98 | + * @return The Topic. |
| 99 | + **/ |
| 100 | + @NonNull |
| 101 | + public String getTopic() { |
| 102 | + return topic; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Returns the Count. |
| 107 | + * |
| 108 | + * @return The Count. |
| 109 | + **/ |
| 110 | + @IntRange(from = 1) |
| 111 | + public int getParticipants() { |
| 112 | + return participants; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Returns the TimestampStart. |
| 117 | + * |
| 118 | + * @return The TimestampStart. |
| 119 | + **/ |
| 120 | + @IntRange(from = 0) |
| 121 | + public long getTimestampStart() { |
| 122 | + return timestampStart; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Returns the TimestampEnd. |
| 127 | + * |
| 128 | + * @return The TimestampEnd. |
| 129 | + **/ |
| 130 | + @IntRange(from = 0) |
| 131 | + public long getTimestampEnd() { |
| 132 | + return timestampEnd; |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Returns the Leader. |
| 137 | + * |
| 138 | + * @return The Leader. |
| 139 | + **/ |
| 140 | + @NonNull |
| 141 | + public String getLeaderId() { |
| 142 | + return leaderId; |
| 143 | + } |
| 144 | + |
| 145 | + @SuppressWarnings("SimplifiableIfStatement") |
| 146 | + @Override |
| 147 | + public boolean equals(Object o) { |
| 148 | + if (this == o) return true; |
| 149 | + if (o == null || getClass() != o.getClass()) return false; |
| 150 | + |
| 151 | + Conference that = (Conference) o; |
| 152 | + |
| 153 | + if (participants != that.participants) return false; |
| 154 | + if (timestampStart != that.timestampStart) return false; |
| 155 | + if (timestampEnd != that.timestampEnd) return false; |
| 156 | + if (!topic.equals(that.topic)) return false; |
| 157 | + return leaderId.equals(that.leaderId); |
| 158 | + |
| 159 | + } |
| 160 | + |
| 161 | + @Override |
| 162 | + public int hashCode() { |
| 163 | + int result = topic.hashCode(); |
| 164 | + result = 31 * result + participants; |
| 165 | + result = 31 * result + (int) (timestampStart ^ (timestampStart >>> 32)); |
| 166 | + result = 31 * result + (int) (timestampEnd ^ (timestampEnd >>> 32)); |
| 167 | + result = 31 * result + leaderId.hashCode(); |
| 168 | + return result; |
| 169 | + } |
| 170 | +} |
0 commit comments