/*******************************************************************************
* Copyright (c) 2005, 2007 committers of openArchitectureWare 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:
* committers of openArchitectureWare - initial API and implementation
*******************************************************************************/
package org.eclipse.xtend.expression;
/**
* @author Sven Efftinge (http://www.efftinge.de)
* @author Arno Haase
*/
public class Variable {
private String name;
private Object value;
public Variable(final String name, final Object value) {
if (name == null)
throw new IllegalArgumentException("name must not be null!");
this.name = name;
this.value = value;
}
public Object getValue() {
return value;
}
public void setValue(final Object value) {
this.value = value;
}
public String getName() {
return name;
}
@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) {
if (other.value != null)
return false;
} else if (!value.equals(other.value))
return false;
return true;
}
@Override
public String toString () {
return "Variable [" + name + "="+ value + "]";
}
}