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

org.jsmpp.session.OutbindParameter Maven / Gradle / Ivy

There is a newer version: 3.0.1
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package org.jsmpp.session;

import org.jsmpp.bean.InterfaceVersion;

/**
 * This class is wraps all bind parameter that will be send as PDU.
 *
 * @author pmoerenhout
 *
 */
public class OutbindParameter {

    private String systemId;
    private String password;
    private InterfaceVersion interfaceVersion;

    /**
     * Construct with all mandatory parameters.
     *
     * @param systemId
     *            is the system id.
     * @param password
     *            is the password.
     */
    public OutbindParameter(String systemId,
                            String password)
    {
        this(systemId, password, InterfaceVersion.IF_34);
    }

    public OutbindParameter(String systemId,
                            String password,
                            InterfaceVersion interfaceVersion)
    {

        this.systemId = systemId;
        this.password = password;
        this.interfaceVersion = interfaceVersion;
    }


    public String getSystemId() {
        return this.systemId;
    }

    public String getPassword() {
        return this.password;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = (prime * result)
                + ((this.password == null) ? 0 : this.password.hashCode());
        result = (prime * result)
                + ((this.systemId == null) ? 0 : this.systemId.hashCode());
        result = (prime * result)
                + ((this.interfaceVersion == null) ? 0 : this.interfaceVersion.hashCode());

        return result;
    }


    private boolean hasEqualPassword(OutbindParameter other) {
        if ((this.password == null) && (other.password != null)) {
            return false;
        }
        return this.password.equals(other.password);
    }

    private boolean hasEqualSystemId(OutbindParameter other) {
        if ((this.systemId == null) && (other.systemId != null)) {
            return false;
        }
        return this.systemId.equals(other.systemId);
    }



    @Override
    public boolean equals(Object obj) {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final OutbindParameter other = (OutbindParameter)obj;

        if (!hasEqualPassword(other)) {
            return false;
        }
        if (!hasEqualSystemId(other)) {
            return false;
        }
        return true;
    }

    public InterfaceVersion getInterfaceVersion() {
        return this.interfaceVersion;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy