Add detailed constructor, equals and hashCode to User object
This commit is contained in:
parent
28a9cf1fdb
commit
9a436910ff
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.telegram.telegrambots.api.interfaces.BotApiObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 3.0
|
||||
@ -35,6 +37,15 @@ public class User implements BotApiObject {
|
||||
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() {
|
||||
return id;
|
||||
}
|
||||
@ -59,6 +70,24 @@ public class User implements BotApiObject {
|
||||
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
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
|
Loading…
Reference in New Issue
Block a user