WIP
[demos/spring/data-jdbc] / src / main / java / de / juplo / kafka / outbox / polling / UserEvent.java
1 package de.juplo.kafka.outbox.polling;
2
3 import org.springframework.context.ApplicationEvent;
4
5
6 public class UserEvent extends ApplicationEvent
7 {
8     public enum Type
9     {
10         CREATED(1),
11         LOGIN(2),
12         LOGOUT(3),
13         DELETED(4);
14
15         public final int num;
16
17
18         Type(int num)
19         {
20             this.num = num;
21         }
22
23
24         public static Type ofInt(int ordinal)
25         {
26             switch (ordinal)
27             {
28                 case 1: return CREATED;
29                 case 2: return LOGIN;
30                 case 3: return LOGOUT;
31                 case 4: return DELETED;
32                 default:
33                     throw new RuntimeException("Unknown ordinal: " + ordinal);
34             }
35         }
36
37         public static int toInt(Type type)
38         {
39             return type.toInt();
40         }
41
42         public int toInt()
43         {
44             return this.num;
45         }
46     }
47
48
49     final Type type;
50     final String user;
51
52
53     public UserEvent(Object source, Type type, String user)
54     {
55         super(source);
56         this.type = type;
57         this.user = user;
58     }
59 }