//# 0 errors, 31 messages
//#
/*
    //#EquatableWeakReference.java:1:1: class: com.dmdirc.util.EquatableWeakReference
    //#EquatableWeakReference.java:1:1: method: com.dmdirc.util.EquatableWeakReference.com.dmdirc.util.EquatableWeakReference__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.util;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * An extension of WeakReference that implements a sane equals and hashcode
 * method.
 * 
 * @param <T> The type of object that this reference contains
 * @author chris
 */
public class EquatableWeakReference<T> extends WeakReference<T> {
    
    /**
     * Creates a new instance of EquatableWeakReference.
     * 
     * @param referent The object that this weak reference should reference.
     */
    public EquatableWeakReference(T referent) {
        super(referent);
    //#EquatableWeakReference.java:43: method: void com.dmdirc.util.EquatableWeakReference.com.dmdirc.util.EquatableWeakReference(Object)
    //#input(void com.dmdirc.util.EquatableWeakReference(Object)): referent
    //#input(void com.dmdirc.util.EquatableWeakReference(Object)): this
    }
    //#EquatableWeakReference.java:44: end of method: void com.dmdirc.util.EquatableWeakReference.com.dmdirc.util.EquatableWeakReference(Object)

    /** {@inheritDoc} */
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Reference) {
    //#EquatableWeakReference.java:49: method: bool com.dmdirc.util.EquatableWeakReference.equals(Object)
    //#input(bool equals(Object)): obj
    //#input(bool equals(Object)): this
    //#output(bool equals(Object)): return_value
    //#presumption(bool equals(Object)): com.dmdirc.util.EquatableWeakReference:get(...)@50 != null
    //#presumption(bool equals(Object)): com.dmdirc.util.EquatableWeakReference:get(...)@52 != null
    //#post(bool equals(Object)): init'ed(return_value)
            return get().equals(((Reference) obj).get());
    //#EquatableWeakReference.java:50: Warning: method not available - call not analyzed
    //#    call on Object com.dmdirc.util.EquatableWeakReference:get()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.util.EquatableWeakReference
    //#    method: bool equals(Object)
    //#    unanalyzed callee: Object com.dmdirc.util.EquatableWeakReference:get()
        } else {
            return get().equals(obj);
    //#EquatableWeakReference.java:52: Warning: method not available - call not analyzed
    //#    call on Object com.dmdirc.util.EquatableWeakReference:get()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.util.EquatableWeakReference
    //#    method: bool equals(Object)
    //#    unanalyzed callee: Object com.dmdirc.util.EquatableWeakReference:get()
    //#EquatableWeakReference.java:52: end of method: bool com.dmdirc.util.EquatableWeakReference.equals(Object)
        }
    }

    /** {@inheritDoc} */
    @Override
    public int hashCode() {
        return get().hashCode();
    //#EquatableWeakReference.java:59: method: int com.dmdirc.util.EquatableWeakReference.hashCode()
    //#EquatableWeakReference.java:59: Warning: method not available - call not analyzed
    //#    call on Object com.dmdirc.util.EquatableWeakReference:get()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.util.EquatableWeakReference
    //#    method: int hashCode()
    //#    unanalyzed callee: Object com.dmdirc.util.EquatableWeakReference:get()
    //#input(int hashCode()): this
    //#output(int hashCode()): return_value
    //#presumption(int hashCode()): com.dmdirc.util.EquatableWeakReference:get(...)@59 != null
    //#post(int hashCode()): init'ed(return_value)
    //#EquatableWeakReference.java:59: end of method: int com.dmdirc.util.EquatableWeakReference.hashCode()
    }
    
}
    //#output(com.dmdirc.util.EquatableWeakReference__static_init): __Descendant_Table[com/dmdirc/util/EquatableWeakReference]
    //#output(com.dmdirc.util.EquatableWeakReference__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(com.dmdirc.util.EquatableWeakReference__static_init): __Dispatch_Table.hashCode()I
    //#post(com.dmdirc.util.EquatableWeakReference__static_init): __Descendant_Table[com/dmdirc/util/EquatableWeakReference] == &__Dispatch_Table
    //#post(com.dmdirc.util.EquatableWeakReference__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(com.dmdirc.util.EquatableWeakReference__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#EquatableWeakReference.java:: end of method: com.dmdirc.util.EquatableWeakReference.com.dmdirc.util.EquatableWeakReference__static_init
    //#EquatableWeakReference.java:: end of class: com.dmdirc.util.EquatableWeakReference
