创建entity模板,equals hashcode 方法模板
如下为FLINK官网实体类demo equals hashcode 方法模板可以参考
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package org.apache.flink.walkthrough.common.entity;
import java.util.Objects;
public final class Transaction {
private long accountId;
private long timestamp;
private double amount;
public Transaction() {
}
public Transaction(long accountId, long timestamp, double amount) {
this.accountId = accountId;
this.timestamp = timestamp;
this.amount = amount;
}
public long getAccountId() {
return this.accountId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
public long getTimestamp() {
return this.timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public double getAmount() {
return this.amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o != null && this.getClass() == o.getClass()) {
Transaction that = (Transaction)o;
return this.accountId == that.accountId && this.timestamp == that.timestamp && Double.compare(that.amount, this.amount) == 0;
} else {
return false;
}
}
public int hashCode() {
return Objects.hash(new Object[]{this.accountId, this.timestamp, this.amount});
}
public String toString() {
return "Transaction{accountId=" + this.accountId + ", timestamp=" + this.timestamp + ", amount=" + this.amount + '}';
}
}
标签:return,timestamp,equals,long,hashcode,amount,public,模板,accountId From: https://www.cnblogs.com/huft/p/18244456