blob: 9c82dfc4ee05ed7ae4fa2c01aface230d162144c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*****************************************************************************
* Copyright (c) 2011 Atos
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Mathieu Velten (Atos) mathieu.velten@atos.net - Initial API and implementation
* Philippe Roland (Atos) philippe.roland@atos.net - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.matching;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
/***
* An IMatchingItem implementation that matches for LinkItems
*
* @author proland
*/
public class LinkItemMatchingItem implements IMatchingItem {
private EObject parent;
private EReference ref;
public LinkItemMatchingItem(EObject parent, EReference ref) {
this.parent = parent;
this.ref = ref;
}
public boolean matchingItemEquals(Object obj) {
if(obj instanceof EReferenceTreeElement) {
if(ref != null && parent != null) {
return parent.equals(((EReferenceTreeElement)obj).getParent()) && ref.equals(((EReferenceTreeElement)obj).getEReference());
}
}
return super.equals(obj);
}
public int matchingItemHashcode() {
if(ref != null && parent != null) {
final int hashPrime1 = 47;
final int hashPrime2 = 13;
return ref.hashCode() * hashPrime1 + parent.hashCode() + hashPrime2;
}
return 0;
}
}
|