package com.project.common.core.absclasses;
|
|
import com.project.common.core.interfaces.ILinkNode;
|
import lombok.Data;
|
import lombok.NoArgsConstructor;
|
|
@Data
|
@NoArgsConstructor
|
public class BaseLinkNode<T> implements ILinkNode<T>
|
{
|
|
|
private T data;
|
|
private BaseLinkNode<T> pre;
|
|
private BaseLinkNode<T> suf;
|
|
private Boolean hasPre = false;
|
|
private Boolean hasSuf = false;
|
|
|
public BaseLinkNode<T> getPre() {
|
return this.getHasPre() ? pre : null;
|
}
|
|
public BaseLinkNode<T> getSuf() {
|
return this.getHasSuf() ? suf : null;
|
}
|
|
public Boolean isHead(){
|
return this.pre == null;
|
}
|
|
public Boolean isLast(){
|
return this.suf == null;
|
}
|
|
|
public Boolean getHasPre()
|
{
|
|
return this.pre != null || this.hasPre;
|
}
|
|
public Boolean getHasSuf()
|
{
|
|
return this.suf != null || this.hasSuf;
|
}
|
|
public boolean equals(final Object o)
|
{
|
if (o == this) {
|
return true;
|
} else if (!(o instanceof BaseLinkNode)) {
|
return false;
|
} else {
|
BaseLinkNode<?> other = (BaseLinkNode)o;
|
if (!other.canEqual(this)) {
|
return false;
|
} else {
|
|
Object this$pre = this.getPre();
|
Object other$pre = other.getPre();
|
if (this$pre == null) {
|
if (other$pre != null) {
|
return false;
|
}
|
} else if (!this$pre.equals(other$pre)) {
|
return false;
|
}
|
|
Object this$suf = this.getSuf();
|
Object other$suf = other.getSuf();
|
if (this$suf == null) {
|
if (other$suf != null) {
|
return false;
|
}
|
} else if (!this$suf.equals(other$suf)) {
|
return false;
|
}
|
|
Object this$data = this.getData();
|
Object other$data = other.getData();
|
if (this$data == null) {
|
if (other$data != null) {
|
return false;
|
}
|
} else if (!this$data.equals(other$data)) {
|
return false;
|
}
|
|
return true;
|
}
|
}
|
}
|
|
protected boolean canEqual(final Object other)
|
{
|
|
return other instanceof BaseLinkNode;
|
}
|
|
public int hashCode()
|
{
|
boolean PRIME = true;
|
int result = 1;
|
Object $pre = this.getPre();
|
result = result * 59 + ($pre == null ? 43 : $pre.hashCode());
|
Object $suf = this.getSuf();
|
result = result * 59 + ($suf == null ? 43 : $suf.hashCode());
|
Object $data = this.getData();
|
result = result * 59 + ($data == null ? 43 : $data.hashCode());
|
return result;
|
}
|
|
public String toString()
|
{
|
return "BaseLinkNode("
|
+ "data=" + this.getData() + ")";
|
// + ", pre=" + this.getPre()
|
// + ", suf=" + this.getSuf() + ")";
|
}
|
|
|
|
}
|