package com.qianwen.core.tool.metadata;
|
|
import java.util.function.Consumer;
|
import com.qianwen.core.tool.utils.StringPool;
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/metadata/ValidateResult.class */
|
public class ValidateResult {
|
private boolean success;
|
private Object value;
|
private String errorMsg;
|
|
public void setSuccess(final boolean success) {
|
this.success = success;
|
}
|
|
public void setValue(final Object value) {
|
this.value = value;
|
}
|
|
public void setErrorMsg(final String errorMsg) {
|
this.errorMsg = errorMsg;
|
}
|
|
public boolean equals(final Object o) {
|
if (o == this) {
|
return true;
|
}
|
if (o instanceof ValidateResult) {
|
ValidateResult other = (ValidateResult) o;
|
if (other.canEqual(this) && isSuccess() == other.isSuccess()) {
|
Object this$value = getValue();
|
Object other$value = other.getValue();
|
if (this$value == null) {
|
if (other$value != null) {
|
return false;
|
}
|
} else if (!this$value.equals(other$value)) {
|
return false;
|
}
|
Object this$errorMsg = getErrorMsg();
|
Object other$errorMsg = other.getErrorMsg();
|
return this$errorMsg == null ? other$errorMsg == null : this$errorMsg.equals(other$errorMsg);
|
}
|
return false;
|
}
|
return false;
|
}
|
|
protected boolean canEqual(final Object other) {
|
return other instanceof ValidateResult;
|
}
|
|
public int hashCode() {
|
int result = (1 * 59) + (isSuccess() ? 79 : 97);
|
Object $value = getValue();
|
int result2 = (result * 59) + ($value == null ? 43 : $value.hashCode());
|
Object $errorMsg = getErrorMsg();
|
return (result2 * 59) + ($errorMsg == null ? 43 : $errorMsg.hashCode());
|
}
|
|
public String toString() {
|
return "ValidateResult(success=" + isSuccess() + ", value=" + getValue() + ", errorMsg=" + getErrorMsg() + StringPool.RIGHT_BRACKET;
|
}
|
|
public ValidateResult(final boolean success, final Object value, final String errorMsg) {
|
this.success = success;
|
this.value = value;
|
this.errorMsg = errorMsg;
|
}
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/metadata/ValidateResult$ValidateResultBuilder.class */
|
public static class ValidateResultBuilder {
|
private boolean success;
|
private Object value;
|
private String errorMsg;
|
|
ValidateResultBuilder() {
|
}
|
|
public ValidateResultBuilder success(final boolean success) {
|
this.success = success;
|
return this;
|
}
|
|
public ValidateResultBuilder value(final Object value) {
|
this.value = value;
|
return this;
|
}
|
|
public ValidateResultBuilder errorMsg(final String errorMsg) {
|
this.errorMsg = errorMsg;
|
return this;
|
}
|
|
public ValidateResult build() {
|
return new ValidateResult(this.success, this.value, this.errorMsg);
|
}
|
|
public String toString() {
|
return "ValidateResult.ValidateResultBuilder(success=" + this.success + ", value=" + this.value + ", errorMsg=" + this.errorMsg + StringPool.RIGHT_BRACKET;
|
}
|
}
|
|
public ValidateResult() {
|
}
|
|
public static ValidateResultBuilder builder() {
|
return new ValidateResultBuilder();
|
}
|
|
public boolean isSuccess() {
|
return this.success;
|
}
|
|
public Object getValue() {
|
return this.value;
|
}
|
|
public String getErrorMsg() {
|
return this.errorMsg;
|
}
|
|
public static ValidateResult success(Object value) {
|
ValidateResult result = new ValidateResult();
|
result.setSuccess(true);
|
result.setValue(value);
|
return result;
|
}
|
|
public static ValidateResult success() {
|
ValidateResult result = new ValidateResult();
|
result.setSuccess(true);
|
return result;
|
}
|
|
public static ValidateResult fail(String message) {
|
ValidateResult result = new ValidateResult();
|
result.setSuccess(false);
|
result.setErrorMsg(message);
|
return result;
|
}
|
|
public Object assertSuccess() {
|
if (!this.success) {
|
throw new IllegalArgumentException(this.errorMsg);
|
}
|
return this.value;
|
}
|
|
public void ifFail(Consumer<ValidateResult> resultConsumer) {
|
if (!this.success) {
|
resultConsumer.accept(this);
|
}
|
}
|
}
|