package com.muyu.mqtt;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.StringUtils;

/**
 * 配置文件 MqttProperties
 *
 * @author Yangle
 * Date 2024/5/29 20:06
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class MqttProperties {

     private    String broker;
     private    String topic ;
     private    String username;
     private    String password;
     private    String clientid;

     public static MqttProperties configBuild(String ip,String topic){
         return MqttProperties.builder()
                 .broker("tcp://"+ip+":1883")
                 .topic(topic)
                 .clientid("protocol-parsing")
                 .build();
     }

     public boolean isLong(){
         return !StringUtils.isBlank(this.username) && !StringUtils.isBlank(this.password);
     }


}
