Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 3c99de2dbd79e04319ebb4a1b6349c7fffd59cf1 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jem.internal.beaninfo.vm;
/*


 */

import java.beans.*;
/**
 * Equality tester for BeanDescriptors
 */
public class BeanDescriptorEquality extends FeatureDescriptorEquality {
	static void INIT() {
		try {
			MAP_EQUALITY.put(BeanDescriptor.class, (BeanDescriptorEquality.class).getConstructor(new Class[] {BeanDescriptor.class}));
		} catch (NoSuchMethodException e) {
		}
	}
	
	/**
	 * Constructor for BeanDescriptorEquality.
	 */
	public BeanDescriptorEquality() {
		super();
	}


	public BeanDescriptorEquality(BeanDescriptor descr) {
		super(descr);
	}
	
	/**
	 * Calculate the hashcode for the current feature, add this
	 * to the hashcode received from super.calculateHashCode
	 * and return the new value.
	 *
	 * NOTE: for subclasses, it is MANDITORY that the first line be:
	 *         int hashcode = super.calculateHashCode();
	 *       and the last line be:
	 *         return hashcode*31 + (your calculated hashcode for just this subclass);
	 */
	protected int calculateHashCode() {
		int hashcode = super.calculateHashCode();
		BeanDescriptor bd = (BeanDescriptor) fFeature;
		int hc = bd.getBeanClass().hashCode();
		if (bd.getCustomizerClass() != null)
			hc += bd.getCustomizerClass().hashCode();
			
		return hashcode*31 + hc;
	}
	 
	public boolean equals(Object obj) {
		if (identityTest(obj))
			return true;
		if (!super.equals(obj))
			return false;
 	
		BeanDescriptor ob = (BeanDescriptor) ((FeatureDescriptorEquality) obj).fFeature;
		BeanDescriptor fb = (BeanDescriptor) fFeature;
 		
		if (ob.getBeanClass() != fb.getBeanClass())
			return false;
		if (ob.getCustomizerClass() != fb.getCustomizerClass())
			return false;
 			
		return true;
	}
}

Back to the top