重写
toString,
https://jueee.github.io/2020/07/2020-07-15-%E5%85%B3%E4%BA%8EtoString%E6%96%B9%E6%B3%95%E7%9A%84%E9%87%8D%E5%86%99%E5%B7%A5%E5%85%B7ToStringBuilder/
hashCode
equeal
clone
引入依赖
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
public class BaseEntity implements Serializable, Cloneable {
/**
* @see Object#toString()
*/
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
/**
* @see Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}