Skip to content

Commit 39fab35

Browse files
committed
Add ActionParameter for messages
1 parent 2134f95 commit 39fab35

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

library/src/main/java/com/proxerme/library/connection/messenger/entity/Message.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.afollestad.bridge.annotations.Body;
88
import com.proxerme.library.interfaces.IdItem;
99
import com.proxerme.library.interfaces.TimeItem;
10+
import com.proxerme.library.parameters.ActionParameter.Action;
1011

1112
/**
1213
* Class that represents a single message.
@@ -62,8 +63,8 @@ public Message[] newArray(int size) {
6263
* @param device The device this message was sent from. In most cases "default".
6364
*/
6465
public Message(@NonNull String id, @NonNull String conferenceId, @NonNull String userId,
65-
@NonNull String username, @NonNull String message, @NonNull String action,
66-
long time, @NonNull String device) {
66+
@NonNull String username, @NonNull String message,
67+
@NonNull @Action String action, long time, @NonNull String device) {
6768
this.id = id;
6869
this.conferenceId = conferenceId;
6970
this.userId = userId;
@@ -87,6 +88,7 @@ protected Message(Parcel in) {
8788

8889
/**
8990
* Returns the id of this message.
91+
*
9092
* @return The id.
9193
*/
9294
@NonNull
@@ -97,6 +99,7 @@ public String getId() {
9799

98100
/**
99101
* Returns the id of the conferenceInfo this message belongs to.
102+
*
100103
* @return The id.
101104
*/
102105
@NonNull
@@ -106,6 +109,7 @@ public String getConferenceId() {
106109

107110
/**
108111
* Returns the id of the user.
112+
*
109113
* @return The id.
110114
*/
111115
@NonNull
@@ -115,6 +119,7 @@ public String getUserId() {
115119

116120
/**
117121
* Returns the username of the user.
122+
*
118123
* @return The username.
119124
*/
120125
@NonNull
@@ -124,6 +129,7 @@ public String getUsername() {
124129

125130
/**
126131
* Returns the actual contents of this message.
132+
*
127133
* @return The contents of this message.
128134
*/
129135
@NonNull
@@ -133,15 +139,18 @@ public String getMessage() {
133139

134140
/**
135141
* Returns the action of this message. Might be empty.
142+
*
136143
* @return The action.
137144
*/
138145
@NonNull
146+
@Action
139147
public String getAction() {
140148
return action;
141149
}
142150

143151
/**
144152
* Returns the time of this message.
153+
*
145154
* @return The time.
146155
*/
147156
@Override
@@ -151,6 +160,7 @@ public long getTime() {
151160

152161
/**
153162
* Returns the device this message was sent from.
163+
*
154164
* @return The device.
155165
*/
156166
@NonNull
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
package com.proxerme.library.parameters;
22

3+
import android.support.annotation.StringDef;
4+
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
import java.lang.annotation.Target;
9+
310
/**
4-
* TODO: Describe class
11+
* Class containing the available actions of a
12+
* {@link com.proxerme.library.connection.messenger.entity.Message}.
513
*
614
* @author Ruben Gees
715
*/
816

917
public class ActionParameter {
1018

19+
public static final String NONE = "";
1120
public static final String ADD_USER = "addUser";
1221
public static final String REMOVE_USER = "removeUser";
22+
public static final String SET_LEADER = "setLeader";
23+
public static final String SET_TOPIC = "setTopic";
24+
25+
/**
26+
* An annotation representing the available actions of a
27+
* {@link com.proxerme.library.connection.messenger.entity.Message}.
28+
*/
29+
@StringDef({NONE, ADD_USER, REMOVE_USER, SET_LEADER, SET_TOPIC})
30+
@Retention(value = RetentionPolicy.SOURCE)
31+
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
32+
public @interface Action {
33+
}
1334

1435
}

0 commit comments

Comments
 (0)