/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 com.acme.spnego;


/**
 * @version $Revision: 531149 $ $Date: $
 */
public final class NegotiationToken implements org.apache.asn1.types.com.acme.spnego.NegotiationTokenType, org.apache.asn1.runtime.ASN1Type
{
    private NegTokenInit negTokenInit;
    private NegTokenTarg negTokenTarg;

    public NegTokenInit getNegTokenInit()
    {
        return negTokenInit;
    }

    public void setNegTokenInit( NegTokenInit negTokenInit )
    {
        this.negTokenInit = negTokenInit;
    }

    public NegTokenTarg getNegTokenTarg()
    {
        return negTokenTarg;
    }

    public void setNegTokenTarg( NegTokenTarg negTokenTarg )
    {
        this.negTokenTarg = negTokenTarg;
    }

    public boolean isConsistent()
    {
        if ( !( ( negTokenInit != null ) ^ ( negTokenTarg != null ) ) )
        {
            return false;
        }

        if ( negTokenInit != null )
        {
            return negTokenInit.isConsistent();
        }
        if ( negTokenTarg != null )
        {
            return negTokenTarg.isConsistent();
        }

        return true;
    }

    public boolean equals( Object obj )
    {
        if ( !( obj instanceof NegotiationToken ) ) return false;

        NegotiationToken negotiationToken = (NegotiationToken) obj;

        if ( negTokenInit != null && !negTokenInit.equals( negotiationToken.negTokenInit ) )
        {
            return false;
        }
        else if ( negotiationToken.negTokenInit != null ) return false;

        if ( negTokenTarg != null && !negTokenTarg.equals( negotiationToken.negTokenTarg ) )
        {
            return false;
        }
        else if ( negotiationToken.negTokenTarg != null ) return false;

        return true;
    }

    public int hashCode()
    {
        int result;
        result = ( negTokenInit != null ? negTokenInit.hashCode() : 0 );
        result = 29 * result + ( negTokenTarg != null ? negTokenTarg.hashCode() : 0 );
        return result;
    }
}
