All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flexport.api.resources.contact.requests.UpdateContact Maven / Gradle / Ivy

The newest version!
package com.flexport.api.resources.contact.requests;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Objects;
import java.util.Optional;

@JsonDeserialize(builder = UpdateContact.Builder.class)
public final class UpdateContact {
    private final Optional name;

    private final Optional email;

    private final Optional phoneNumber;

    private int _cachedHashCode;

    UpdateContact(Optional name, Optional email, Optional phoneNumber) {
        this.name = name;
        this.email = email;
        this.phoneNumber = phoneNumber;
    }

    /**
     * @return Updated name of the contact.
     */
    @JsonProperty("name")
    public Optional getName() {
        return name;
    }

    /**
     * @return Updated email address of the contact.
     */
    @JsonProperty("email")
    public Optional getEmail() {
        return email;
    }

    /**
     * @return Updated phone number of the contact.
     */
    @JsonProperty("phone_number")
    public Optional getPhoneNumber() {
        return phoneNumber;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) return true;
        return other instanceof UpdateContact && equalTo((UpdateContact) other);
    }

    private boolean equalTo(UpdateContact other) {
        return name.equals(other.name) && email.equals(other.email) && phoneNumber.equals(other.phoneNumber);
    }

    @Override
    public int hashCode() {
        if (_cachedHashCode == 0) {
            _cachedHashCode = Objects.hash(this.name, this.email, this.phoneNumber);
        }
        return _cachedHashCode;
    }

    @Override
    public String toString() {
        return "UpdateContact{" + "name: " + name + ", email: " + email + ", phoneNumber: " + phoneNumber + "}";
    }

    public static Builder builder() {
        return new Builder();
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static final class Builder {
        private Optional name = Optional.empty();

        private Optional email = Optional.empty();

        private Optional phoneNumber = Optional.empty();

        private Builder() {}

        public Builder from(UpdateContact other) {
            name(other.getName());
            email(other.getEmail());
            phoneNumber(other.getPhoneNumber());
            return this;
        }

        @JsonSetter(value = "name", nulls = Nulls.SKIP)
        public Builder name(Optional name) {
            this.name = name;
            return this;
        }

        public Builder name(String name) {
            this.name = Optional.of(name);
            return this;
        }

        @JsonSetter(value = "email", nulls = Nulls.SKIP)
        public Builder email(Optional email) {
            this.email = email;
            return this;
        }

        public Builder email(String email) {
            this.email = Optional.of(email);
            return this;
        }

        @JsonSetter(value = "phone_number", nulls = Nulls.SKIP)
        public Builder phoneNumber(Optional phoneNumber) {
            this.phoneNumber = phoneNumber;
            return this;
        }

        public Builder phoneNumber(String phoneNumber) {
            this.phoneNumber = Optional.of(phoneNumber);
            return this;
        }

        public UpdateContact build() {
            return new UpdateContact(name, email, phoneNumber);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy