001/*
002 * Copyright (c) 2011-2017 Nexmo Inc
003 *
004 * Permission is hereby granted, free of charge, to any person obtaining a copy
005 * of this software and associated documentation files (the "Software"), to deal
006 * in the Software without restriction, including without limitation the rights
007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008 * copies of the Software, and to permit persons to whom the Software is
009 * furnished to do so, subject to the following conditions:
010 *
011 * The above copyright notice and this permission notice shall be included in
012 * all copies or substantial portions of the Software.
013 *
014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
020 * THE SOFTWARE.
021 */
022package com.nexmo.client.voice;
023
024import com.fasterxml.jackson.annotation.JsonInclude;
025import org.apache.commons.lang3.builder.EqualsBuilder;
026import org.apache.commons.lang3.builder.HashCodeBuilder;
027
028@JsonInclude(value = JsonInclude.Include.NON_NULL)
029public class PhoneEndpoint implements Endpoint {
030    private String type = "phone";
031    private String number;
032    private String dtmfAnswer = null;
033
034    public PhoneEndpoint() {
035    }
036
037    public PhoneEndpoint(String number) {
038        this.number = number;
039    }
040
041    public PhoneEndpoint(String number, String dtmfAnswer) {
042        this.number = number;
043        this.dtmfAnswer = dtmfAnswer;
044    }
045
046    @Override
047    public String getType() {
048        return type;
049    }
050
051    @Override
052    public String toLog() {
053        return number;
054    }
055
056    public String getNumber() {
057        return number;
058    }
059
060    public void setNumber(String number) {
061        this.number = number;
062    }
063
064    public String getDtmfAnswer() {
065        return dtmfAnswer;
066    }
067
068    public void setDtmfAnswer(String dtmfAnswer) {
069        this.dtmfAnswer = dtmfAnswer;
070    }
071
072    @Override
073    public boolean equals(Object obj) {
074        if (obj == null) {
075            return false;
076        }
077        if (obj == this) {
078            return true;
079        }
080        if (obj.getClass() != getClass()) {
081            return false;
082        }
083        PhoneEndpoint rhs = (PhoneEndpoint) obj;
084        return new EqualsBuilder()
085                .append(this.type, rhs.type)
086                .append(this.number, rhs.number)
087                .append(this.dtmfAnswer, rhs.dtmfAnswer)
088                .isEquals();
089    }
090
091    @Override
092    public int hashCode() {
093        return new HashCodeBuilder(277, 11)
094                .append(this.type)
095                .append(this.number)
096                .append(this.dtmfAnswer)
097                .toHashCode();
098    }
099}