表名info就Info - 容易记
src/main/java/com/artchips/bean/Info.java
public class Info {
private Integer id;
private String username;
private String password;
public Info(){}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "Info [id=" + id + ", username=" + username + ", password=" + password + "]";
}
/*
* 参照阿里的开发规范,集合处理
* 关于 hashCode 和 equals 的处理,遵循如下规则:
* 1) 只要重写 equals ,就必须重写 hashCode 。
* 2) 因为 Set存储的是不重复的对象,依据 hashCode 和 equals 进行判断,所以 Set 存储的
* 对象必须重写这两个方法。
* 3) 如果自定义对象作为 Map 的键,那么必须重写 hashCode 和 equals 。
* 说明: String 重写了 hashCode 和 equals 方法,所以我们可以非常愉快地使用 String 对象作为 key 来使用。
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((password == null) ? 0 : password.hashCode());
result = prime * result + ((username == null) ? 0 : username.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Info other = (Info) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (username == null) {
if (other.username != null)
return false;
} else if (!username.equals(other.username))
return false;
return true;
}
}