@Override
 public MqttConnectOptions getConnectionOptions() {
   MqttConnectOptions options = new MqttConnectOptions();
   if (this.cleanSession != null) {
     options.setCleanSession(this.cleanSession);
   }
   if (this.connectionTimeout != null) {
     options.setConnectionTimeout(this.connectionTimeout);
   }
   if (this.keepAliveInterval != null) {
     options.setKeepAliveInterval(this.keepAliveInterval);
   }
   if (this.password != null) {
     options.setPassword(this.password.toCharArray());
   }
   if (this.socketFactory != null) {
     options.setSocketFactory(this.socketFactory);
   }
   if (this.sslProperties != null) {
     options.setSSLProperties(this.sslProperties);
   }
   if (this.userName != null) {
     options.setUserName(this.userName);
   }
   if (this.will != null) {
     options.setWill(
         this.will.getTopic(), this.will.getPayload(), this.will.getQos(), this.will.isRetained());
   }
   if (this.serverURIs != null) {
     options.setServerURIs(this.serverURIs);
   }
   return options;
 }