001package org.intellimate.izou.sdk.events; 002 003import org.intellimate.izou.identification.Identifiable; 004import org.intellimate.izou.sdk.contentgenerator.EventListener; 005import org.intellimate.izou.sdk.frameworks.presence.events.LeavingEvent; 006import org.intellimate.izou.sdk.frameworks.presence.events.PresenceEvent; 007 008import java.util.Optional; 009 010/** 011 * A collection of common Event-Listeners, Descriptions and Types, see 012 * <a href="https://github.com/intellimate/Izou/wiki/Common-IDs">online document</a> 013 * @author LeanderK 014 * @version 1.0 015 */ 016//implementation: every added EventListener should be added in the registerStandardMethod in EventPropertiesAssistant 017public class CommonEvents { 018 019 /** 020 * if the type of event is based on comparing the current time a fixed or dynamic time AND the of the other systems 021 * reaction should be consistent ignoring environment variables 022 * @param identifiable the identifiable ot associate the EventListener with 023 * @return an optional which may contain an EventListener 024 */ 025 public Optional<EventListener> alarmListener(Identifiable identifiable) { 026 return EventListener.createEventListener( 027 ALARM_DESCRIPTOR, 028 "if the type of event is based on comparing the current time a fixed or dynamic time AND the of the " 029 + "other systems reaction should be consistent ignoring environment variables", 030 "izou_alarm", 031 identifiable 032 ); 033 } 034 035 /** 036 * if the type of event is based on comparing the current time a fixed or dynamic time AND the of the other systems 037 * reaction should be consistent ignoring environment variables 038 */ 039 public static final String ALARM_DESCRIPTOR = "izou.alarm"; 040 041 /** 042 * the common EventListeners and Descriptors associated with the Presence 043 */ 044 public static class Presence { 045 /** 046 * this event does indicate some kind of presence, strict or general. 047 * <p> 048 * Important: there is no authentication provided, if the descriptor: UNKNOWN_DESCRIPTOR is added to the 049 * event. Only if the descriptor: KNOWN_DESCRIPTOR is added, one should conclude that this is the actual user. 050 * </p> 051 * @param identifiable the identifiable ot associate the EventListener with 052 * @return an optional which may contain an EventListener 053 */ 054 public static Optional<EventListener> presenceListener(Identifiable identifiable) { 055 return EventListener.createEventListener( 056 PresenceEvent.ID, 057 "this event does indicate some kind of presence, strict or general", 058 "izou_presence", 059 identifiable 060 ); 061 } 062 063 /** 064 * this event does indicate some kind of leaving, strict or general 065 * <p> 066 * Important: there is no authentication provided, if the descriptor: UNKNOWN_DESCRIPTOR is added to the 067 * event. Only if the descriptor: KNOWN_DESCRIPTOR is added, one should conclude that this is the actual user. 068 * </p> 069 * @param identifiable the identifiable ot associate the EventListener with 070 * @return an optional which may contain an EventListener 071 */ 072 public static Optional<EventListener> leavingListener(Identifiable identifiable) { 073 return EventListener.createEventListener( 074 LeavingEvent.ID, 075 "this event does indicate some kind of leaving, strict or general", 076 "izou_presence_leaving", 077 identifiable 078 ); 079 } 080 081 /** 082 * this event does not mean the user is able to notice anything (can be used for warm-up), it indicates 083 * he might be. 084 * <p> 085 * Important: there is no authentication provided, if the descriptor: UNKNOWN_DESCRIPTOR is added to the 086 * event. Only if the descriptor: KNOWN_DESCRIPTOR is added, one should conclude that this is the actual user. 087 * </p> 088 * @param identifiable the identifiable ot associate the EventListener with 089 * @return an optional which may contain an EventListener 090 */ 091 public static Optional<EventListener> generalListener(Identifiable identifiable) { 092 return EventListener.createEventListener( 093 PresenceEvent.GENERAL_DESCRIPTOR, 094 "this event does not mean the user is able to notice anything (can be used for warm-up), it " + 095 "indicates he might be", 096 "izou_presence_general", 097 identifiable 098 ); 099 } 100 101 /** 102 * it means the user has probably left (he could have left a while ago) 103 * @param identifiable the identifiable ot associate the EventListener with 104 * @return an optional which may contain an EventListener 105 */ 106 public static Optional<EventListener> generalLeavingListener(Identifiable identifiable) { 107 return EventListener.createEventListener( 108 LeavingEvent.GENERAL_DESCRIPTOR, 109 "it means the user has probably left (he could have left a while ago)", 110 "izou_presence_general_leaving", 111 identifiable 112 ); 113 } 114 115 /** 116 * it means that the addon can guarantee that the user entered an area near izou. 117 * <p> 118 * Important: there is no authentication provided, if the descriptor: UNKNOWN_DESCRIPTOR is added to the 119 * event. Only if the descriptor: KNOWN_DESCRIPTOR is added, one should conclude that this is the actual user. 120 * </p> 121 * @param identifiable the identifiable ot associate the EventListener with 122 * @return an optional which may contain an EventListener 123 */ 124 public static Optional<EventListener> strictListener(Identifiable identifiable) { 125 return EventListener.createEventListener( 126 PresenceEvent.STRICT_DESCRIPTOR, 127 "it means that the addon can guarantee that the user entered an area near izou", 128 "izou_presence_strict", 129 identifiable 130 ); 131 } 132 133 /** 134 * it means the user has most likely left (he may come back immediately) 135 * @param identifiable the identifiable ot associate the EventListener with 136 * @return an optional which may contain an EventListener 137 */ 138 public static Optional<EventListener> strictLeavingListener(Identifiable identifiable) { 139 return EventListener.createEventListener( 140 LeavingEvent.STRICT_DESCRIPTOR, 141 "it means the user has most likely left (he may come back immediately)", 142 "izou_presence_strict_leaving", 143 identifiable 144 ); 145 } 146 } 147 148 /** 149 * the common EventListeners and Descriptors associated with the Response 150 */ 151 public static class Response { 152 /** 153 * Event for maximum response. Every component that can contribute should contribute to this Event. 154 * Examples: alarm, User coming home etc. Handle them carefully, they should be only fired rarely! 155 * @param identifiable the identifiable ot associate the EventListener with 156 * @return an optional which may contain an EventListener 157 */ 158 public static Optional<EventListener> fullResponseListener(Identifiable identifiable) { 159 return EventListener.createEventListener( 160 FULL_RESPONSE_DESCRIPTOR, 161 "Event for maximum response. Every component that can contribute should contribute to this " + 162 "Event. Examples: alarm, User coming home etc. Handle them carefully, they should be only " + 163 "fired rarely!", 164 "izou_full_response", 165 identifiable 166 ); 167 } 168 169 /** 170 * Event for maximum response. Every component that can contribute should contribute to this Event. 171 * Examples: alarm, User coming home etc. Handle them carefully, they should be only fired rarely! 172 */ 173 public static final String FULL_RESPONSE_DESCRIPTOR = "izou.FullResponse"; 174 175 /** 176 * Event for major response. Every component that is import should contribute to this Event. MajorResponse 177 * is intended to be the most common Response-Event 178 * @param identifiable the identifiable ot associate the EventListener with 179 * @return an optional which may contain an EventListener 180 */ 181 public static Optional<EventListener> majorResponseListener(Identifiable identifiable) { 182 return EventListener.createEventListener( 183 MAJOR_RESPONSE_DESCRIPTOR, 184 "Event for major response. Every component that is import should contribute to this Event. " + 185 "MajorResponse is intended to be the most common Response-Event", 186 "izou_major_response", 187 identifiable 188 ); 189 } 190 191 /** 192 * Event for major response. Every component that is import should contribute to this Event. MajorResponse 193 * is intended to be the most common Response-Event 194 */ 195 public static final String MAJOR_RESPONSE_DESCRIPTOR = "izou.MajorResponse"; 196 197 /** 198 * Event for a Welcome with minor response. Only components that have information of great 199 * importance should contribute to this event! 200 * @param identifiable the identifiable ot associate the EventListener with 201 * @return an optional which may contain an EventListener 202 */ 203 public static Optional<EventListener> minorResponseListener(Identifiable identifiable) { 204 return EventListener.createEventListener( 205 MINOR_RESPONSE_DESCRIPTOR, 206 "Event for a Welcome with minor response. Only components that have information of great importance " + 207 "should contribute to this event!", 208 "izou_minor_response", 209 identifiable 210 ); 211 } 212 213 /** 214 * Event for a Welcome with minor response. Only components that have information of great 215 * importance should contribute to this event! 216 */ 217 public static final String MINOR_RESPONSE_DESCRIPTOR = "izou.MinorResponse"; 218 } 219 220 /** 221 * the common EventListeners and Types 222 */ 223 public static class Type { 224 /** 225 * Event-Type which indicates that other AddOns should react to this Event. 226 * @param identifiable the identifiable ot associate the EventListener with 227 * @return an optional which may contain an EventListener 228 */ 229 public static Optional<EventListener> responseListener(Identifiable identifiable) { 230 return EventListener.createEventListener( 231 RESPONSE_TYPE, 232 "Event-Type which indicates that other AddOns should react to this Event.", 233 "izou_response", 234 identifiable 235 ); 236 } 237 238 /** 239 * Event-Type which indicates that other AddOns should react to this Event. 240 */ 241 public static final String RESPONSE_TYPE = "response"; 242 243 /** 244 * Event-Type which indicates that only your AddOn should react to an Event 245 * @param identifiable the identifiable ot associate the EventListener with 246 * @return an optional which may contain an EventListener 247 */ 248 public static Optional<EventListener> notificationListener(Identifiable identifiable) { 249 return EventListener.createEventListener( 250 NOTIFICATION_TYPE, 251 "Event-Type which indicates that only your AddOn should react to an Event", 252 "izou_notification", 253 identifiable 254 ); 255 } 256 257 /** 258 * Event-Type which indicates that only your AddOn should react to an Event 259 */ 260 public static final String NOTIFICATION_TYPE = "notification"; 261 } 262 263 /** 264 * common descriptors 265 */ 266 public static class Descriptors { 267 /** 268 * Event-Type which indicates that this events stops an already running addon 269 * @param identifiable the identifiable ot associate the EventListener with 270 * @return an optional which may contain an EventListener 271 */ 272 public static Optional<EventListener> stopListener(Identifiable identifiable) { 273 return EventListener.createEventListener( 274 STOP_DESCRIPTOR, 275 "Event-Type which indicates that that this events stops an already running addon", 276 "izou_stop", 277 identifiable 278 ); 279 } 280 /** 281 * Event-Type which indicates that this events stops an already running addon 282 */ 283 public static final String STOP_DESCRIPTOR = "stop"; 284 285 /** 286 * Event-type which indicates that this event is important and should not get cancelled 287 */ 288 public static final String NOT_INTERRUPT = "notinterrupt"; 289 } 290}