Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4dce8ce5705bf4bb18d96615c36f9512dd12ef87 (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
/*******************************************************************************
 * Copyright (c) 2000, 2009 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.core;

import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.internal.core.util.Util;

public class MemberValuePair implements IMemberValuePair {

	String memberName;
	public Object value;
	public int valueKind = K_UNKNOWN;

	public MemberValuePair(String memberName) {
		this.memberName = memberName;
	}

	public MemberValuePair(String memberName, Object value, int valueKind) {
		this(memberName);
		this.value = value;
		this.valueKind = valueKind;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof MemberValuePair)) {
			return false;
		}
		MemberValuePair other = (MemberValuePair) obj;
		return
			this.valueKind == other.valueKind
			&& this.memberName.equals(other.memberName)
			&& (this.value == other.value
				|| (this.value != null && this.value.equals(other.value))
				|| (this.value instanceof Object[] && other.value instanceof Object[] && Util.equalArraysOrNull((Object[])this.value, (Object[]) other.value)));
	}

	@Override
	public String getMemberName() {
		return this.memberName;
	}

	@Override
	public Object getValue() {
		return this.value;
	}

	@Override
	public int getValueKind() {
		return this.valueKind;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.memberName == null) ? 0 : this.memberName.hashCode());
		result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
		result = prime * result + this.valueKind;
		return result;
	}
}

Back to the top