Merge pull request #454 from addo37/augment-user
Add detailed constructor, equals and hashCode to User object
This commit is contained in:
commit
e2bdf7ff73
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import org.telegram.telegrambots.api.interfaces.BotApiObject;
|
import org.telegram.telegrambots.api.interfaces.BotApiObject;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 3.0
|
* @version 3.0
|
||||||
@ -35,6 +37,15 @@ public class User implements BotApiObject {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User(Integer id, String firstName, Boolean isBot, String lastName, String userName, String languageCode) {
|
||||||
|
this.id = id;
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.isBot = isBot;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.userName = userName;
|
||||||
|
this.languageCode = languageCode;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -59,6 +70,24 @@ public class User implements BotApiObject {
|
|||||||
return isBot;
|
return isBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
User user = (User) o;
|
||||||
|
return Objects.equals(id, user.id) &&
|
||||||
|
Objects.equals(firstName, user.firstName) &&
|
||||||
|
Objects.equals(isBot, user.isBot) &&
|
||||||
|
Objects.equals(lastName, user.lastName) &&
|
||||||
|
Objects.equals(userName, user.userName) &&
|
||||||
|
Objects.equals(languageCode, user.languageCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, firstName, isBot, lastName, userName, languageCode);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User{" +
|
return "User{" +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user