View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.handler.codec.mqtt;
18  
19  import io.netty.util.internal.StringUtil;
20  
21  /**
22   * Variable Header for the {@link MqttConnectMessage}
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  
36      public MqttConnectVariableHeader(
37              String name,
38              int version,
39              boolean hasUserName,
40              boolean hasPassword,
41              boolean isWillRetain,
42              int willQos,
43              boolean isWillFlag,
44              boolean isCleanSession,
45              int keepAliveTimeSeconds) {
46          this.name = name;
47          this.version = version;
48          this.hasUserName = hasUserName;
49          this.hasPassword = hasPassword;
50          this.isWillRetain = isWillRetain;
51          this.willQos = willQos;
52          this.isWillFlag = isWillFlag;
53          this.isCleanSession = isCleanSession;
54          this.keepAliveTimeSeconds = keepAliveTimeSeconds;
55      }
56  
57      public String name() {
58          return name;
59      }
60  
61      public int version() {
62          return version;
63      }
64  
65      public boolean hasUserName() {
66          return hasUserName;
67      }
68  
69      public boolean hasPassword() {
70          return hasPassword;
71      }
72  
73      public boolean isWillRetain() {
74          return isWillRetain;
75      }
76  
77      public int willQos() {
78          return willQos;
79      }
80  
81      public boolean isWillFlag() {
82          return isWillFlag;
83      }
84  
85      public boolean isCleanSession() {
86          return isCleanSession;
87      }
88  
89      public int keepAliveTimeSeconds() {
90          return keepAliveTimeSeconds;
91      }
92  
93      @Override
94      public String toString() {
95          return new StringBuilder(StringUtil.simpleClassName(this))
96              .append('[')
97              .append("name=").append(name)
98              .append(", version=").append(version)
99              .append(", hasUserName=").append(hasUserName)
100             .append(", hasPassword=").append(hasPassword)
101             .append(", isWillRetain=").append(isWillRetain)
102             .append(", isWillFlag=").append(isWillFlag)
103             .append(", isCleanSession=").append(isCleanSession)
104             .append(", keepAliveTimeSeconds=").append(keepAliveTimeSeconds)
105             .append(']')
106             .toString();
107     }
108 }