package org.obda.query.domain.imp;

import org.obda.query.domain.Variable;

import com.sun.msv.datatype.xsd.XSDatatype;

public class VariableImpl implements Variable{

	private String name= null;
	private int identifier = Integer.MIN_VALUE;
	private XSDatatype type = null;

	
	protected VariableImpl(String name, int identifier, XSDatatype type){
		this.name = name;
//		this.identifier = identifier;
		this.identifier = name.hashCode();
		this.type = type;
	}

	 public boolean equals(Object obj){
		 if(obj == null || !(obj instanceof Variable)){
			 return false;
		 }
		 //return this.hash() == ((VariableImpl)obj).hash();
		 return this.hashCode() == ((VariableImpl)obj).hashCode();
	 }

	 public int hashCode(){
		 return identifier;
	 }

	
	public String getName() {
		return name;
	}

	public String toString() {
		return getName();
	}
	
	public Variable copy() {
		return new VariableImpl(new String(name), identifier, type);
	}
	
}

package org.obda.query.domain.imp;

import org.obda.query.domain.Variable;

import com.sun.msv.datatype.xsd.XSDatatype;

public class VariableImpl implements Variable {

	private String name = null;
	private XSDatatype type = null;
	private int identifier = -1;

	protected VariableImpl(String name, XSDatatype type) {
		this.name = name;
		this.type = type;
		this.identifier = name.hashCode();
	}

	@Override
	public boolean equals(Object obj) {

		if(obj == null || !(obj instanceof VariableImpl))
			 return false;

		VariableImpl name2 = (VariableImpl) obj;
		return this.identifier == name2.identifier;
	 }

	@Override
	public int hashCode() {
		 return identifier;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String toString() {
		return getName();
	}

	@Override
	public Variable copy() {
		return new VariableImpl(new String(name), this.type);
	}
}

Remove the parameter identifier from the object constructor.
Remove the parameter identifier from the object constructor.
