com.dahuatech.icc.multiinone.event.domain.SimpleEventSubcribeInfo Maven / Gradle / Ivy
The newest version!
package com.dahuatech.icc.multiinone.event.domain;
import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.multiinone.utils.StringUtils;
import com.dahuatech.icc.multiinone.vo.BaseRequest;
import java.util.List;
import java.util.Map;
/**
* 简易订阅信息
*/
public class SimpleEventSubcribeInfo extends BaseRequest {
/**接收地址*/
private String receiveIp;
/**接收端口*/
private String receivePort;
/**接收URI,相对路径*/
private String uri;
/**协议类型*/
private boolean isHttps = false;
/**订阅者名称*/
private String name;
/**类型列表配置*/
private Map> typesConfigs;
public String getReceiveIp() {
return receiveIp;
}
public void setReceiveIp(String receiveIp) {
this.receiveIp = receiveIp;
}
public String getReceivePort() {
if(StringUtils.isEmpty(receivePort)){
return isHttps?"443" : "80";
}
return receivePort;
}
public void setReceivePort(String receivePort) {
this.receivePort = receivePort;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean https) {
isHttps = https;
}
public String getName() {
if(StringUtils.isEmpty(name)){
return receiveIp + "_" + receivePort;
}
return name;
}
public void setName(String name) {
this.name = name;
}
public Map> getTypesConfigs() {
return typesConfigs;
}
public void setTypesConfigs(Map> typesConfigs) {
this.typesConfigs = typesConfigs;
}
public void businessValid() {
if(StringUtils.isEmpty(receiveIp)){
throw new BusinessException("接收ip为空");
}
if(StringUtils.isEmpty(uri)){
throw new BusinessException("接收uri为空");
}
if(uri.startsWith("http")){
throw new BusinessException("接收uri格式非法|相对路径");
}
if(typesConfigs == null || typesConfigs.size() == 0){
throw new BusinessException("类型列表配置为空");
}
}
}