1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.handler.codec.mqtt;
18
19 import io.netty.util.internal.StringUtil;
20
21
22
23
24 public final class MqttConnectVariableHeader {
25
26 private final String name;
27 private final int version;
28 private final boolean hasUserName;
29 private final boolean hasPassword;
30 private final boolean isWillRetain;
31 private final int willQos;
32 private final boolean isWillFlag;
33 private final boolean isCleanSession;
34 private final int keepAliveTimeSeconds;
35 private final MqttProperties properties;
36
37 public MqttConnectVariableHeader(
38 String name,
39 int version,
40 boolean hasUserName,
41 boolean hasPassword,
42 boolean isWillRetain,
43 int willQos,
44 boolean isWillFlag,
45 boolean isCleanSession,
46 int keepAliveTimeSeconds) {
47 this(name,
48 version,
49 hasUserName,
50 hasPassword,
51 isWillRetain,
52 willQos,
53 isWillFlag,
54 isCleanSession,
55 keepAliveTimeSeconds,
56 MqttProperties.NO_PROPERTIES);
57 }
58
59 public MqttConnectVariableHeader(
60 String name,
61 int version,
62 boolean hasUserName,
63 boolean hasPassword,
64 boolean isWillRetain,
65 int willQos,
66 boolean isWillFlag,
67 boolean isCleanSession,
68 int keepAliveTimeSeconds,
69 MqttProperties properties) {
70 this.name = name;
71 this.version = version;
72 this.hasUserName = hasUserName;
73 this.hasPassword = hasPassword;
74 this.isWillRetain = isWillRetain;
75 this.willQos = willQos;
76 this.isWillFlag = isWillFlag;
77 this.isCleanSession = isCleanSession;
78 this.keepAliveTimeSeconds = keepAliveTimeSeconds;
79 this.properties = MqttProperties.withEmptyDefaults(properties);
80 }
81
82 public String name() {
83 return name;
84 }
85
86 public int version() {
87 return version;
88 }
89
90 public boolean hasUserName() {
91 return hasUserName;
92 }
93
94 public boolean hasPassword() {
95 return hasPassword;
96 }
97
98 public boolean isWillRetain() {
99 return isWillRetain;
100 }
101
102 public int willQos() {
103 return willQos;
104 }
105
106 public boolean isWillFlag() {
107 return isWillFlag;
108 }
109
110 public boolean isCleanSession() {
111 return isCleanSession;
112 }
113
114 public int keepAliveTimeSeconds() {
115 return keepAliveTimeSeconds;
116 }
117
118 public MqttProperties properties() {
119 return properties;
120 }
121
122 @Override
123 public String toString() {
124 return new StringBuilder(StringUtil.simpleClassName(this))
125 .append('[')
126 .append("name=").append(name)
127 .append(", version=").append(version)
128 .append(", hasUserName=").append(hasUserName)
129 .append(", hasPassword=").append(hasPassword)
130 .append(", isWillRetain=").append(isWillRetain)
131 .append(", isWillFlag=").append(isWillFlag)
132 .append(", isCleanSession=").append(isCleanSession)
133 .append(", keepAliveTimeSeconds=").append(keepAliveTimeSeconds)
134 .append(']')
135 .toString();
136 }
137 }