fix: SpotBugs扫描分析(二):修复子父类equals()方法不对称问题(需用getClass而不是instanceof做判断)

pull/66/head
xiaoxiamo 6 months ago
parent a50ac0e73e
commit 298ec9703d

@ -2,6 +2,8 @@ package com.java3y.austin.common.dto.account.sms;
import lombok.*; import lombok.*;
import java.util.Objects;
/** /**
* <span>Form File</span> * <span>Form File</span>
* <p>Description</p> * <p>Description</p>
@ -13,7 +15,6 @@ import lombok.*;
* @Description * @Description
* @see com.java3y.austin.common.dto.account austin * @see com.java3y.austin.common.dto.account austin
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@ -30,4 +31,36 @@ public class LinTongSmsAccount extends SmsAccount {
private String userName; private String userName;
private String password; private String password;
/**
* equals
*
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
LinTongSmsAccount that = (LinTongSmsAccount) o;
return url.equals(that.url) &&
userName.equals(that.userName) &&
password.equals(that.password);
}
/**
* hashCode
*
* @return
*/
@Override
public int hashCode() {
return Objects.hash(url, userName, password);
}
} }

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
*/ */
@ -27,5 +29,33 @@ public class SmsAccount {
*/ */
protected String scriptName; protected String scriptName;
/**
* equals
*
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SmsAccount that = (SmsAccount) o;
return supplierId.equals(that.supplierId) &&
supplierName.equals(that.supplierName) &&
scriptName.equals(that.scriptName);
}
/**
* hashCode
*
* @return
*/
@Override
public int hashCode() {
return Objects.hash(supplierId, supplierName, scriptName);
}
} }

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Objects;
/** /**
* *
* <p> * <p>
@ -42,4 +44,41 @@ public class TencentSmsAccount extends SmsAccount {
private String smsSdkAppId; private String smsSdkAppId;
private String templateId; private String templateId;
private String signName; private String signName;
/**
* equals
*
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
TencentSmsAccount that = (TencentSmsAccount) o;
return url.equals(that.url) &&
region.equals(that.region) &&
secretId.equals(that.secretId) &&
secretKey.equals(that.secretKey) &&
smsSdkAppId.equals(that.smsSdkAppId) &&
templateId.equals(that.templateId) &&
signName.equals(that.signName);
}
/**
* hashCode
*
* @return
*/
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), url, region, secretId, secretKey, smsSdkAppId, templateId, signName);
}
} }

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Objects;
/** /**
* *
* <p> * <p>
@ -31,4 +33,36 @@ public class YunPianSmsAccount extends SmsAccount {
*/ */
private String url; private String url;
/**
* equals
*
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
YunPianSmsAccount that = (YunPianSmsAccount) o;
return apikey.equals(that.apikey) &&
tplId.equals(that.tplId) &&
url.equals(that.url);
}
/**
* hashCode
*
* @return
*/
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), apikey, tplId, url);
}
} }

Loading…
Cancel
Save