package kr.gmtc.gicoms.pg.tss;

import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class SetTest {

	public static void main(String[] args) {
		Set<TestCls> testSet = ConcurrentHashMap.newKeySet();
		
		TestCls c1 = new TestCls(1,"asdf",3L);
		TestCls c2 = new TestCls(1,"asdf",3L);
		TestCls c3 = new TestCls(1,"asdf",3L);
		TestCls c4 = new TestCls(1,"asdf",3L);
		
		c1.setD(true);

		c3.setD(false);
		
		testSet.add(c1);
		testSet.add(c2);
		testSet.add(c3);
		testSet.add(c4);
		
		
		for (TestCls testCls : testSet) {
			System.out.println(testCls);
		}
		
		
	}
	
	
}

class TestCls{
	
	private int a;
	private String b;
	private long c;
	private boolean d; 
	public TestCls(int a, String b, long c) {
		this.a=a;
		this.b=b;
		this.c=c;
	}

	
	
	public boolean isD() {
		return d;
	}



	public void setD(boolean d) {
		this.d = d;
	}




    @Override
	public String toString() {
		return "TestCls [a=" + a + ", b=" + b + ", c=" + c + ", d=" + d + "]";
	}



	@Override
    public int hashCode() {
        return (this.a+this.b+this.c).hashCode();
    }
    
    @Override
    public boolean equals(Object obj) {
        //p1.equals(p2)
        if(obj instanceof TestCls) {
        	TestCls p = (TestCls)obj;
            return this.hashCode()==p.hashCode(); 
            
        }
        return false;
    }
	
}