1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.beep4j.internal;
17
18 import net.sf.beep4j.ChannelHandler;
19 import net.sf.beep4j.ProfileInfo;
20
21 public abstract class StartChannelResponse {
22
23 private StartChannelResponse() {
24
25 }
26
27 public abstract boolean isCancelled();
28
29 public int getCode() {
30 throw new IllegalStateException("StartChannelRequest is not cancelled");
31 }
32
33 public String getMessage() {
34 throw new IllegalStateException("StartChannelRequest is not cancelled");
35 }
36
37 public ProfileInfo getProfile() {
38 throw new IllegalStateException("StartChannelRequest is cancelled");
39 }
40
41 public ChannelHandler getChannelHandler() {
42 throw new IllegalStateException("StartChannelRequest is cancelled");
43 }
44
45 public static final StartChannelResponse createCancelledResponse(
46 final int code, final String message) {
47 return new StartChannelResponse() {
48 @Override
49 public boolean isCancelled() {
50 return true;
51 }
52 @Override
53 public int getCode() {
54 return code;
55 }
56 @Override
57 public String getMessage() {
58 return message;
59 }
60 };
61 }
62
63 public static final StartChannelResponse createSuccessResponse(
64 final ProfileInfo profile, final ChannelHandler channelHandler) {
65 return new StartChannelResponse() {
66 @Override
67 public boolean isCancelled() {
68 return false;
69 }
70 @Override
71 public ChannelHandler getChannelHandler() {
72 return channelHandler;
73 }
74 @Override
75 public ProfileInfo getProfile() {
76 return profile;
77 }
78 };
79 }
80
81 }