blob: f265503debe498cf60cee9d9d49c6e73e47a1868 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/******************************************************************************
* Copyright (c) 2005,2020 Sven Efftinge, CEA LIST, Artal and others.
* All rights reserved. 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:
* Sven Efftinge - Initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.xpand.model;
import org.eclipse.emf.ecore.EClassifier;
/**
* FIXME Do we need Variables now, with explicit OCLEnvironment available?
* @author Sven Efftinge
* @author Arno Haase
*/
public class Variable {
private final String name;
private final Object value;
private final EClassifier type;
/**
* type and value may be null
*/
public Variable(final String name, final EClassifier type, final Object value) {
if (name == null) {
throw new NullPointerException("name must not be null!");
}
this.name = name;
this.type = type;
this.value = value;
}
public Object getValue() {
return value;
}
public String getName() {
return name;
}
public EClassifier getType() {
return type;
}
@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((name == null) ? 0 : name.hashCode());
result = PRIME * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Variable other = (Variable) obj;
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (value == null) {
return other.value == null;
} else {
return value.equals(other.value);
}
}
@Override
public String toString () {
return "Variable [" + name + "="+ value + "]";
}
}
|