|
| 1 | +package com.proxerme.library.connection.messenger.entity; |
| 2 | + |
| 3 | +import android.os.Parcel; |
| 4 | +import android.os.Parcelable; |
| 5 | +import android.support.annotation.IntRange; |
| 6 | + |
| 7 | +import com.afollestad.bridge.annotations.Body; |
| 8 | + |
| 9 | +/** |
| 10 | + * Class that represents the constants of the messaging module. Such as max text length, request limits, |
| 11 | + * e.g. how many conferences at once could be requested. |
| 12 | + * |
| 13 | + * @author Desnoo |
| 14 | + */ |
| 15 | +public class Constants implements Parcelable { |
| 16 | + public static final Creator<Constants> CREATOR = new Creator<Constants>() { |
| 17 | + @Override |
| 18 | + public Constants createFromParcel(Parcel in) { |
| 19 | + return new Constants(in); |
| 20 | + } |
| 21 | + |
| 22 | + @Override |
| 23 | + public Constants[] newArray(int size) { |
| 24 | + return new Constants[size]; |
| 25 | + } |
| 26 | + }; |
| 27 | + |
| 28 | + @Body(name = "textCount") |
| 29 | + int textCount; |
| 30 | + @Body(name = "conferenceLimit") |
| 31 | + int conferenceLimit; |
| 32 | + @Body(name = "messagesLimit") |
| 33 | + int messagesLimit; |
| 34 | + @Body(name = "userLimit") |
| 35 | + int userLimit; |
| 36 | + @Body(name = "topicCount") |
| 37 | + int topicCount; |
| 38 | + |
| 39 | + /** |
| 40 | + * Private constructor. |
| 41 | + */ |
| 42 | + Constants() { |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * The Constructor. |
| 47 | + * |
| 48 | + * @param textCount The max length of a message. |
| 49 | + * @param conferenceLimit The max number of conferences to request with one request. |
| 50 | + * @param messagesLimit The max number of messages of a conference to request with one request. |
| 51 | + * @param userLimit The max count of users of an conference. |
| 52 | + * @param topicCount The max length of a conference topic. |
| 53 | + */ |
| 54 | + public Constants(@IntRange(from = 0) int textCount, @IntRange(from = 0) int conferenceLimit, |
| 55 | + @IntRange(from = 0) int messagesLimit, @IntRange(from = 0) int userLimit, |
| 56 | + @IntRange(from = 0) int topicCount) { |
| 57 | + this.textCount = textCount; |
| 58 | + this.conferenceLimit = conferenceLimit; |
| 59 | + this.messagesLimit = messagesLimit; |
| 60 | + this.userLimit = userLimit; |
| 61 | + this.topicCount = topicCount; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * The Constructor to parse from a parcel. |
| 66 | + * |
| 67 | + * @param in The parcel to parse. |
| 68 | + */ |
| 69 | + protected Constants(Parcel in) { |
| 70 | + textCount = in.readInt(); |
| 71 | + conferenceLimit = in.readInt(); |
| 72 | + messagesLimit = in.readInt(); |
| 73 | + userLimit = in.readInt(); |
| 74 | + topicCount = in.readInt(); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Returns the max length of a message. |
| 79 | + * |
| 80 | + * @return The max length of a message. |
| 81 | + */ |
| 82 | + @IntRange(from = 0) |
| 83 | + public int getTextCount() { |
| 84 | + return textCount; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Returns the max number of conferences that can be requested by {@link com.proxerme.library.connection.messenger.request.ConferencesRequest} |
| 89 | + * with one request to the API. |
| 90 | + * |
| 91 | + * @return The max number of conferences to request with one request. |
| 92 | + */ |
| 93 | + @IntRange(from = 0) |
| 94 | + public int getConferenceLimit() { |
| 95 | + return conferenceLimit; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Returns the max number of messages of an conference that can be requested by {@link com.proxerme.library.connection.messenger.request.MessagesRequest} |
| 100 | + * one request to the API. |
| 101 | + * |
| 102 | + * @return The max number of messages that can be requested for an conference. |
| 103 | + */ |
| 104 | + @IntRange(from = 0) |
| 105 | + public int getMessagesLimit() { |
| 106 | + return messagesLimit; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Returns the max count of users that can be part of an conference. |
| 111 | + * |
| 112 | + * @return The max count of users of a conference. |
| 113 | + */ |
| 114 | + @IntRange(from = 0) |
| 115 | + public int getUserLimit() { |
| 116 | + return userLimit; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Returns the max length of the conference topic. |
| 121 | + * |
| 122 | + * @return The max length of the conference topic. |
| 123 | + */ |
| 124 | + @IntRange(from = 0) |
| 125 | + public int getTopicCount() { |
| 126 | + return topicCount; |
| 127 | + } |
| 128 | + |
| 129 | + |
| 130 | + @Override |
| 131 | + public int describeContents() { |
| 132 | + return 0; |
| 133 | + } |
| 134 | + |
| 135 | + @Override |
| 136 | + public void writeToParcel(Parcel parcel, int i) { |
| 137 | + parcel.writeInt(textCount); |
| 138 | + parcel.writeInt(conferenceLimit); |
| 139 | + parcel.writeInt(messagesLimit); |
| 140 | + parcel.writeInt(userLimit); |
| 141 | + parcel.writeInt(topicCount); |
| 142 | + } |
| 143 | + |
| 144 | + @SuppressWarnings("SimplifiableIfStatement") |
| 145 | + @Override |
| 146 | + public boolean equals(Object o) { |
| 147 | + if (this == o) return true; |
| 148 | + if (o == null || getClass() != o.getClass()) return false; |
| 149 | + Constants constants = (Constants) o; |
| 150 | + if (textCount != constants.textCount) return false; |
| 151 | + if (conferenceLimit != constants.conferenceLimit) return false; |
| 152 | + if (messagesLimit != constants.messagesLimit) return false; |
| 153 | + if (userLimit != constants.userLimit) return false; |
| 154 | + return topicCount == constants.topicCount; |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public int hashCode() { |
| 159 | + int result = textCount; |
| 160 | + result = 31 * result + conferenceLimit; |
| 161 | + result = 31 * result + messagesLimit; |
| 162 | + result = 31 * result + userLimit; |
| 163 | + result = 31 * result + topicCount; |
| 164 | + return result; |
| 165 | + } |
| 166 | +} |
0 commit comments