2828import java .util .ArrayList ;
2929import java .util .List ;
3030import co .aurasphere .botmill .kik .configuration .Authentication ;
31+ import co .aurasphere .botmill .kik .incoming .event .AnyEvent ;
3132import co .aurasphere .botmill .kik .incoming .event .LinkMessageEvent ;
3233import co .aurasphere .botmill .kik .incoming .event .PictureMessageEvent ;
3334import co .aurasphere .botmill .kik .incoming .event .TextMessageEvent ;
4041/**
4142 * KikBotMillContext
4243 *
43- * This class is used to access all globally defined objects being used on the application.
44- * Developers will be able to do the following using this class:
44+ * This class is used to access all globally defined objects being used on the
45+ * application. Developers will be able to do the following using this class:
4546 *
46- * - Setup the environment (Api and username)
47- * - Get and Set the list of domains, action frames and broadcast frames
48- * - Get and Set the Entrypoints.
47+ * - Setup the environment (Api and username) - Get and Set the list of domains,
48+ * action frames and broadcast frames - Get and Set the Entrypoints.
4949 *
5050 * @author Alvin P. Reyes
5151 */
5252public class KikBotMillContext {
53-
53+
5454 /** The instance. */
5555 private static KikBotMillContext instance ;
56-
56+
5757 /** The authentication. */
5858 private Authentication authentication ;
59-
59+
6060 /** The webhook url. */
6161 private String webhookUrl ;
62-
62+
6363 /** The bots. */
6464 private List <KikBotMillEntry > entryPoints ;
65-
65+
6666 /** The domains. */
6767 private List <Domain > domains ;
68-
68+
6969 /** The action frames. */
7070 private List <Frame > actionFrames ;
71-
72- /** The text message action frames. */
73- private List <Frame > textMessageActionFrames ;
74-
75- /** The media message action frames. */
76- private List <Frame > mediaMessageActionFrames ;
77-
78- /** The link message action frames. */
79- private List <Frame > linkMessageActionFrames ;
71+
72+ /** The any event action frames. */
73+ private List <Frame > anyEventActionFrames ;
8074
8175 /** The broadcast action frames. */
8276 private List <Frame > broadcastActionFrames ;
83-
77+
8478 /**
85- * Get the list of domains.
86- *
87- * @return list of {@link Domain}
79+ * Instantiates a new kik bot mill context.
8880 */
89- public List <Domain > getDomains () {
90- return domains ;
81+ public KikBotMillContext () {
82+ this .entryPoints = new ArrayList <KikBotMillEntry >();
83+ this .domains = new ArrayList <Domain >();
84+ this .actionFrames = new ArrayList <Frame >();
85+ this .anyEventActionFrames = new ArrayList <Frame >();
86+ this .broadcastActionFrames = new ArrayList <Frame >();
9187 }
9288
9389 /**
94- * Get the list of action frames .
90+ * Gets the single instance of KikBotMillContext .
9591 *
96- * @return list of {@link ActionFrame}
92+ * @return {@link KikBotMillContext} single instance of KikBotMillContext
9793 */
98- public List <Frame > getActionFrames () {
99- return actionFrames ;
94+ public static KikBotMillContext getInstance () {
95+ if (instance == null ) {
96+ instance = new KikBotMillContext ();
97+ }
98+ return instance ;
10099 }
101100
102101 /**
103- * Gets the text message action frames .
102+ * Get the list of domains .
104103 *
105- * @return list of text message {@link Frame }
104+ * @return list of {@link Domain }
106105 */
107- public List <Frame > getTextMessageActionFrames () {
108- return textMessageActionFrames ;
106+ public List <Domain > getDomains () {
107+ return domains ;
109108 }
110109
111110 /**
112- * Gets the media message action frames.
111+ * Get the list of action frames.
113112 *
114- * @return list of media message {@link Frame }
113+ * @return list of {@link ActionFrame }
115114 */
116- public List <Frame > getMediaMessageActionFrames () {
117- return mediaMessageActionFrames ;
115+ public List <Frame > getActionFrames () {
116+ return actionFrames ;
118117 }
119118
120119 /**
121- * Gets the link message action frames.
120+ * Gets the any event action frames.
122121 *
123- * @return list of link message {@link Frame}
122+ * @return the any event action frames
124123 */
125- public List <Frame > getLinkMessageActionFrames () {
126- return linkMessageActionFrames ;
124+ public List <Frame > getAnyEventActionFrames () {
125+ return anyEventActionFrames ;
127126 }
128127
129128 /**
130129 * Gets the broadcast message action frames.
131130 *
132- * @return list of broadcast message{@link Frame}
131+ * @return the broadcast message action frames
133132 */
134133 public List <Frame > getBroadcastMessageActionFrames () {
135134 return broadcastActionFrames ;
136135 }
137136
138- /**
139- * Instantiates a new kik bot mill context.
140- */
141- public KikBotMillContext () {
142- this .entryPoints = new ArrayList <KikBotMillEntry >();
143- this .domains = new ArrayList <Domain >();
144- this .actionFrames = new ArrayList <Frame >();
145- this .textMessageActionFrames = new ArrayList <Frame >();
146- this .mediaMessageActionFrames = new ArrayList <Frame >();
147- this .linkMessageActionFrames = new ArrayList <Frame >();
148- this .broadcastActionFrames = new ArrayList <Frame >();
149- }
150-
151- /**
152- * Gets the single instance of KikBotMillContext.
153- *
154- * @return {@link KikBotMillContext} single instance of KikBotMillContext
155- */
156- public static KikBotMillContext getInstance () {
157- if (instance == null ) {
158- instance = new KikBotMillContext ();
159- }
160- return instance ;
161- }
162-
163137 /**
164138 * Gets the user.
165139 *
166140 * @return the user
167141 */
168- public String getUser (){
142+ public String getUser () {
169143 return this .authentication .getUser ();
170144 }
171-
145+
172146 /**
173147 * Gets the api key.
174148 *
@@ -177,37 +151,41 @@ public String getUser(){
177151 public String getApiKey () {
178152 return this .authentication .getApiKey ();
179153 }
180-
154+
181155 /**
182156 * Setup.
183157 *
184- * @param username the username
185- * @param apiKey the api key
158+ * @param username
159+ * the username
160+ * @param apiKey
161+ * the api key
186162 */
187163 public void setup (String username , String apiKey ) {
188164 this .authentication = new Authentication ();
189165 this .authentication .setUser (username );
190166 this .authentication .setApiKey (apiKey );
191167 }
192-
168+
193169 /**
194170 * Register kik bot.
195171 *
196- * @param kikBotMillEntry the kikBotMillEntry
172+ * @param kikBotMillEntry
173+ * the kikBotMillEntry
197174 */
198175 public void registerEntryPoint (KikBotMillEntry kikBotMillEntry ) {
199176 this .entryPoints .add (kikBotMillEntry );
200177 }
201-
178+
202179 /**
203180 * Sets the web hook url.
204181 *
205- * @param url the new web hook url
182+ * @param url
183+ * the new web hook url
206184 */
207185 public void setWebHookUrl (String url ) {
208186 this .webhookUrl = url ;
209187 }
210-
188+
211189 /**
212190 * Gets the web hook url.
213191 *
@@ -216,58 +194,52 @@ public void setWebHookUrl(String url) {
216194 public String getWebHookUrl () {
217195 return this .webhookUrl ;
218196 }
219-
197+
220198 /**
221199 * Register domain.
222200 *
223- * @param domain the domain
201+ * @param domain
202+ * the domain
224203 */
225204 public void registerDomain (Domain domain ) {
226205 this .domains .add (domain );
227206 }
228-
207+
229208 /**
230209 * Adds the action frame to context.
231210 *
232- * @param actionFrame the action frame
211+ * @param actionFrame
212+ * the action frame
233213 */
234214 public void addActionFrameToContext (Frame actionFrame ) {
235- if ((actionFrame .getEvent () instanceof TextMessageEvent ) || (actionFrame .getEvent () instanceof TextMessagePatternEvent )){
236- this .textMessageActionFrames .add (actionFrame );
237- }else if ((actionFrame .getEvent () instanceof LinkMessageEvent )) {
238- this .linkMessageActionFrames .add (actionFrame );
239- }else if ((actionFrame .getEvent () instanceof PictureMessageEvent )
240- ||(actionFrame .getEvent () instanceof VideoMessageEvent )) {
241- this .mediaMessageActionFrames .add (actionFrame );
242- }else {
215+ if (actionFrame .getEvent () instanceof AnyEvent ) {
216+ this .anyEventActionFrames .add (actionFrame );
217+ } else {
243218 this .actionFrames .add (actionFrame );
244219 }
245220 }
246-
221+
247222 /**
248223 * Adds the action frames to context.
249224 *
250- * @param frames the frames
225+ * @param frames
226+ * the frames
251227 */
252228 public void addActionFramesToContext (List <Frame > frames ) {
253- for (Frame actionFrame :frames ) {
254- if ((actionFrame .getEvent () instanceof TextMessageEvent ) || (actionFrame .getEvent () instanceof TextMessagePatternEvent )){
255- this .textMessageActionFrames .add (actionFrame );
256- }else if ((actionFrame .getEvent () instanceof LinkMessageEvent )) {
257- this .linkMessageActionFrames .add (actionFrame );
258- }else if ((actionFrame .getEvent () instanceof PictureMessageEvent )
259- ||(actionFrame .getEvent () instanceof VideoMessageEvent )) {
260- this .mediaMessageActionFrames .add (actionFrame );
261- }else {
229+ for (Frame actionFrame : frames ) {
230+ if (actionFrame .getEvent () instanceof AnyEvent ) {
231+ this .anyEventActionFrames .add (actionFrame );
232+ } else {
262233 this .actionFrames .add (actionFrame );
263234 }
264235 }
265236 }
266-
237+
267238 /**
268239 * Adds the action frame to broadcast.
269240 *
270- * @param actionFrame the action frame
241+ * @param actionFrame
242+ * the action frame
271243 */
272244 public void addActionFrameToBroadcast (Frame actionFrame ) {
273245 this .broadcastActionFrames .add (actionFrame );
0 commit comments