1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.timeout;
17
18 import io.netty.channel.Channel;
19 import io.netty.util.internal.ObjectUtil;
20 import io.netty.util.internal.StringUtil;
21
22
23
24
25 public class IdleStateEvent {
26 public static final IdleStateEvent FIRST_READER_IDLE_STATE_EVENT =
27 new DefaultIdleStateEvent(IdleState.READER_IDLE, true);
28 public static final IdleStateEvent READER_IDLE_STATE_EVENT =
29 new DefaultIdleStateEvent(IdleState.READER_IDLE, false);
30 public static final IdleStateEvent FIRST_WRITER_IDLE_STATE_EVENT =
31 new DefaultIdleStateEvent(IdleState.WRITER_IDLE, true);
32 public static final IdleStateEvent WRITER_IDLE_STATE_EVENT =
33 new DefaultIdleStateEvent(IdleState.WRITER_IDLE, false);
34 public static final IdleStateEvent FIRST_ALL_IDLE_STATE_EVENT =
35 new DefaultIdleStateEvent(IdleState.ALL_IDLE, true);
36 public static final IdleStateEvent ALL_IDLE_STATE_EVENT =
37 new DefaultIdleStateEvent(IdleState.ALL_IDLE, false);
38
39 private final IdleState state;
40 private final boolean first;
41
42
43
44
45
46
47
48 protected IdleStateEvent(IdleState state, boolean first) {
49 this.state = ObjectUtil.checkNotNull(state, "state");
50 this.first = first;
51 }
52
53
54
55
56 public IdleState state() {
57 return state;
58 }
59
60
61
62
63 public boolean isFirst() {
64 return first;
65 }
66
67 @Override
68 public String toString() {
69 return StringUtil.simpleClassName(this) + '(' + state + (first ? ", first" : "") + ')';
70 }
71
72 private static final class DefaultIdleStateEvent extends IdleStateEvent {
73 private final String representation;
74
75 DefaultIdleStateEvent(IdleState state, boolean first) {
76 super(state, first);
77 this.representation = "IdleStateEvent(" + state + (first ? ", first" : "") + ')';
78 }
79
80 @Override
81 public String toString() {
82 return representation;
83 }
84 }
85 }