com.github.messenger4j.send.recipient.PhoneNumberRecipient Maven / Gradle / Ivy
// Generated by delombok at Tue May 07 22:31:27 CEST 2019
package com.github.messenger4j.send.recipient;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import java.util.Optional;
import lombok.NonNull;
/**
* @author Max Grabenhorst
* @since 1.0.0
*/
public final class PhoneNumberRecipient extends Recipient {
private final String phoneNumber;
private final Optional firstName;
private final Optional lastName;
private PhoneNumberRecipient(
String phoneNumber, Optional firstName, Optional lastName) {
this.phoneNumber = phoneNumber;
this.firstName = firstName;
this.lastName = lastName;
}
public static PhoneNumberRecipient create(@NonNull String phoneNumber) {
if (phoneNumber == null) {
throw new java.lang.IllegalArgumentException("phoneNumber is marked @NonNull but is null");
}
return new PhoneNumberRecipient(phoneNumber, empty(), empty());
}
public static PhoneNumberRecipient create(
@NonNull String phoneNumber, @NonNull String firstName, @NonNull String lastName) {
if (phoneNumber == null) {
throw new java.lang.IllegalArgumentException("phoneNumber is marked @NonNull but is null");
}
if (firstName == null) {
throw new java.lang.IllegalArgumentException("firstName is marked @NonNull but is null");
}
if (lastName == null) {
throw new java.lang.IllegalArgumentException("lastName is marked @NonNull but is null");
}
return new PhoneNumberRecipient(phoneNumber, of(firstName), of(lastName));
}
public String phoneNumber() {
return phoneNumber;
}
public Optional firstName() {
return firstName;
}
public Optional lastName() {
return lastName;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public java.lang.String toString() {
return "PhoneNumberRecipient(phoneNumber="
+ this.phoneNumber
+ ", firstName="
+ this.firstName
+ ", lastName="
+ this.lastName
+ ")";
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof PhoneNumberRecipient)) return false;
final PhoneNumberRecipient other = (PhoneNumberRecipient) o;
if (!other.canEqual((java.lang.Object) this)) return false;
final java.lang.Object this$phoneNumber = this.phoneNumber;
final java.lang.Object other$phoneNumber = other.phoneNumber;
if (this$phoneNumber == null
? other$phoneNumber != null
: !this$phoneNumber.equals(other$phoneNumber)) return false;
final java.lang.Object this$firstName = this.firstName;
final java.lang.Object other$firstName = other.firstName;
if (this$firstName == null ? other$firstName != null : !this$firstName.equals(other$firstName))
return false;
final java.lang.Object this$lastName = this.lastName;
final java.lang.Object other$lastName = other.lastName;
if (this$lastName == null ? other$lastName != null : !this$lastName.equals(other$lastName))
return false;
return true;
}
@java.lang.SuppressWarnings("all")
protected boolean canEqual(final java.lang.Object other) {
return other instanceof PhoneNumberRecipient;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
final int PRIME = 59;
int result = 1;
final java.lang.Object $phoneNumber = this.phoneNumber;
result = result * PRIME + ($phoneNumber == null ? 43 : $phoneNumber.hashCode());
final java.lang.Object $firstName = this.firstName;
result = result * PRIME + ($firstName == null ? 43 : $firstName.hashCode());
final java.lang.Object $lastName = this.lastName;
result = result * PRIME + ($lastName == null ? 43 : $lastName.hashCode());
return result;
}
}