alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 * Created on Nov 10, 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.netbeans.modules.javacore.jmiimpl.javamodel;

import javax.jmi.reflect.RefAssociationLink;
import javax.jmi.reflect.RefObject;

import org.netbeans.jmi.javamodel.Element;

/** RefAssociationLink implementation. 
 * 
 * @author Vladimir Hudec
 *
 */
public class AssociationLinkImpl implements RefAssociationLink {
    
    private final Element end1;
    private final Element end2;
    
    AssociationLinkImpl(Element end1, Element end2) {
        if (end1 == null || end2 == null)
            throw new NullPointerException();
        this.end1 = end1;
        this.end2 = end2;
    }
    
    public RefObject refFirstEnd() {
        return end1;
    }
    
    public RefObject refSecondEnd() {
        return end2;
    }
    
    public boolean equals(Object other) {
        if (other instanceof AssociationLinkImpl) {
            return this == other;
        } else {
            return (other instanceof RefAssociationLink) && 
                ((RefAssociationLink) other).refFirstEnd().equals(refFirstEnd()) && 
                ((RefAssociationLink) other).refSecondEnd().equals(refSecondEnd());
        }
    }
    
    public int hashCode() {
        return (refFirstEnd().refMofId() + refSecondEnd().refMofId()).hashCode();
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.