/* * Copyright (c) 2012 Data Harmonisation Panel * * All rights reserved. This program and the accompanying materials are made * available under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * HUMBOLDT EU Integrated Project #030962 * Data Harmonisation Panel <http://www.dhpanel.eu> */ package eu.esdihumboldt.hale.ui.common.graph.content; import net.jcip.annotations.Immutable; import eu.esdihumboldt.util.Pair; /** * Represents an edge in a cell/entity graph. */ @Immutable public class Edge extends Pair<Object, Object> { private final String name; /** * Create an edge * * @param first the source node * @param second the destination node * @param name the edge name, may be <code>null</code> */ public Edge(Object first, Object second, String name) { super(first, second); this.name = name; } /** * @return the name */ public String getName() { return name; } /** * @see Object#toString() */ @Override public String toString() { return getName(); } /** * @see Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } /** * @see Object#equals(Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Edge other = (Edge) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; } }