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);
	}
	
}

@@ -165,16 +165,17 @@
 Variable
+ 
 %7B%0D%0A%0D%0A%09pr
@@ -191,16 +191,17 @@
 ing name
+ 
 = null;%0D
@@ -214,82 +214,64 @@
 ate 
-int identifier = Integer.MIN_VALUE;%0D%0A%09private XSDatatype type = null;%0D%0A%0D%0A%09
+XSDatatype type = null;%0D%0A%09private int identifier = -1;%0D%0A
 %0D%0A%09p
@@ -308,24 +308,8 @@
 ame,
- int identifier,
  XSD
@@ -321,16 +321,17 @@
 pe type)
+ 
 %7B%0D%0A%09%09thi
@@ -350,40 +350,26 @@
 e;%0D%0A
-//
 %09%09this.
-identifier = identifier
+type = type
 ;%0D%0A%09
@@ -410,36 +410,26 @@
 ;%0D%0A%09
-%09this.type = type;%0D%0A%09%7D%0D%0A
+%7D%0D%0A%0D%0A%09@Override
 %0D%0A%09
- 
 publ
@@ -457,22 +457,24 @@
 ect obj)
-%7B
+ %7B%0D%0A
 %0D%0A%09%09
- 
 if(obj =
@@ -512,11 +512,14 @@
 able
+Impl
 ))
-%7B
 %0D%0A%09%09
@@ -539,42 +539,33 @@
 e;%0D%0A
-%09%09 %7D%0D%0A%09%09 //return this.hash() =
+%0D%0A%09%09VariableImpl name2 
 = 
-(
 (Var
@@ -578,25 +578,17 @@
 mpl)
+ 
 obj
-).hash()
 ;%0D%0A%09%09
- 
 retu
@@ -599,64 +599,61 @@
 his.
-hashCode() == ((VariableImpl)obj).hashCode();%0D%0A%09 %7D%0D%0A%0D%0A%09 
+identifier == name2.identifier;%0D%0A%09 %7D%0D%0A%0D%0A%09@Override%0D%0A%09
 publ
@@ -669,16 +669,17 @@
 shCode()
+ 
 %7B%0D%0A%09%09 re
@@ -697,23 +697,31 @@
 fier;%0D%0A%09
- 
 %7D%0D%0A%0D%0A%09
+@Override
 %0D%0A%09publi
@@ -764,16 +764,28 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09@Override%0D%0A
 %09public 
@@ -830,17 +830,28 @@
 );%0D%0A%09%7D%0D%0A
-%09
+%0D%0A%09@Override
 %0D%0A%09publi
@@ -919,20 +919,13 @@
 e), 
-identifier, 
+this.
 type
@@ -936,10 +936,7 @@
 %09%7D%0D%0A
-%09%0D%0A
 %7D%0D%0A

Remove the parameter identifier from the object constructor.