/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.service.protocol;

/**
 * The <tt>ContactResource</tt> class represents a resource, from which a
 * <tt>Contact</tt> is connected.
 *
 * @author Yana Stamcheva
 */
public class ContactResource
{
    /**
     * A static instance of this class representing the base resource. If this
     * base resource is passed as a parameter for any operation (send message,
     * call) the operation should explicitly use the base contact address. This
     * is meant to force a call or a message sending to all the resources for
     * the corresponding contact.
     */
    public static ContactResource BASE_RESOURCE = new ContactResource();

    /**
     * The contact, to which this resource belongs.
     */
    private Contact contact;

    /**
     * The name of this contact resource.
     */
    private String resourceName;

    /**
     * The presence status of this contact resource.
     */
    protected PresenceStatus presenceStatus;

    /**
     * The priority of this contact source.
     */
    protected int priority;

    /**
     * Whether this contact resource is a mobile one.
     */
    protected boolean mobile = false;

    /**
     * Creates an empty instance of <tt>ContactResource</tt> representing the
     * base resource.
     */
    public ContactResource() {}

    /**
     * Creates a <tt>ContactResource</tt> by specifying the
     * <tt>resourceName</tt>, the <tt>presenceStatus</tt> and the
     * <tt>priority</tt>.
     *
     * @param contact the parent <tt>Contact</tt> this resource is about
     * @param resourceName the name of this resource
     * @param presenceStatus the presence status of this resource
     * @param priority the priority of this resource
     */
    public ContactResource( Contact contact,
                            String resourceName,
                            PresenceStatus presenceStatus,
                            int priority,
                            boolean mobile)
    {
        this.contact = contact;
        this.resourceName = resourceName;
        this.presenceStatus = presenceStatus;
        this.priority = priority;
        this.mobile = mobile;
    }

    /**
     * Returns the <tt>Contact</tt>, this resources belongs to.
     *
     * @return the <tt>Contact</tt>, this resources belongs to
     */
    public Contact getContact()
    {
        return contact;
    }

    /**
     * Returns the name of this resource.
     *
     * @return the name of this resource
     */
    public String getResourceName()
    {
        return resourceName;
    }

    /**
     * Returns the presence status of this resource.
     *
     * @return the presence status of this resource
     */
    public PresenceStatus getPresenceStatus()
    {
        return presenceStatus;
    }

    /**
     * Returns the priority of the resources.
     *
     * @return the priority of this resource
     */
    public int getPriority()
    {
        return priority;
    }

    /**
     * Whether contact is mobile one. Logged in only from mobile device.
     * @return whether contact is mobile one.
     */
    public boolean isMobile()
    {
        return mobile;
    }
}

@@ -3319,11 +3319,782 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public int hashCode()%0A    %7B%0A        final int prime = 31;%0A        int result = 1;%0A        result =%0A            prime * result%0A                + ((resourceName == null) ? 0 : resourceName.hashCode());%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj)%0A    %7B%0A        if (this == obj)%0A            return true;%0A        if (obj == null)%0A            return false;%0A        if (getClass() != obj.getClass())%0A            return false;%0A        ContactResource other = (ContactResource) obj;%0A        if (resourceName == null)%0A        %7B%0A            if (other.resourceName != null)%0A                return false;%0A        %7D%0A        else if (!resourceName.equals(other.resourceName))%0A            return false;%0A        return true;%0A    %7D
 %0A%7D%0A

Define ContactResource equality based on resourceName. (fixes OTR issue)