Bug 135837 [Viewers] Problems with TreeSelection#equals(..) and StructuredSelection#equals(..)
N20060410-0010 TreeSelection#equals(..) is not symmetric with StructuredSelection#equals(..): - TreeSelection#equals(..) is always false if the argument is not instanceof TreeSelection - StructuredSelection.equals(..) can be true if the argument is a TreeSelection 3 Problems: (1) equals(..) should be symmetric, as defined in Object#equals(..) (2) hashCode() of both classes must return the same if objects are equal (currently, StructuredSelection#hashCode() is not even implemented!) (3) equality is currently only defined for the implementations. Should be defined on interfaces, since clients generally only know about the interface, not the implementation.
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeSelection.java
public int hashCode() {
		int code = getClass().hashCode();
		if (paths != null) {
			for (int i = 0; i < paths.length; i++) {
				code = code * 17 + elementHashCode(paths[i]);
			}
		}
		return code;
	}
	public TreePath[] getPaths() {
		return paths==null ? EMPTY_TREE_PATHS : (TreePath[]) paths.clone();
	}
	
	public TreePath[] getPathsFor(Object element) {
		Object value= element2TreePaths==null ? null : element2TreePaths.get(element);
		if (value == null) {
			return EMPTY_TREE_PATHS;
		} else if (value instanceof TreePath) {
			return new TreePath[] { (TreePath)value };
		} else if (value instanceof List) {
			List l= (List)value;
			return (TreePath[])l.toArray(new TreePath[l.size()]);
		} else {
			
			Assert.isTrue(false, "Unhandled case"); 
			return null;
		}
	}
}