InfoScreenHeartBeatPacket.java 2.43 KB
package com.yoho.rfid.model.req;

import com.yoho.rfid.util.DateUtil;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
 * Created by chenchao on 2017/10/16.
 */

public class InfoScreenHeartBeatPacket {
    private String ip;

    private String mac;

    private Integer screenType;

    private Long updateDateTime;

    private String updateDateTimeStr;

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public Integer getScreenType() {
        return screenType;
    }

    public void setScreenType(Integer screenType) {
        this.screenType = screenType;
    }

    public Long getUpdateDateTime() {
        return updateDateTime;
    }

    public void setUpdateDateTime(Long updateDateTime) {
        this.updateDateTime = updateDateTime;
    }

    public String getUpdateDateTimeStr() {
        if (Objects.nonNull(updateDateTime)){
            Date date = new Date(updateDateTime);
            return new SimpleDateFormat(DateUtil.DATE_TIME_FORMAT).format(date);
        }
        return updateDateTimeStr;
    }

    public void setUpdateDateTimeStr(String updateDateTimeStr) {
        this.updateDateTimeStr = updateDateTimeStr;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("ip", ip)
                .append("mac", mac)
                .append("screenType", screenType)
                .append("updateDateTime", updateDateTime)
                .append("updateDateTimeStr", updateDateTimeStr)
                .toString();
    }


    public class DataBuilder{
        private InfoScreenHeartBeatPacket packet = new InfoScreenHeartBeatPacket();
        public DataBuilder setIp(String ip){
            packet.setIp(ip);
            return this;
        }

        public DataBuilder setMac(String mac){
            packet.setMac(mac);
            return this;
        }

        public DataBuilder setScreenType(Integer screenType){
            packet.setScreenType(screenType);
            return this;
        }

        public InfoScreenHeartBeatPacket build(){
            return packet;
        }
    }
}