Example usage for org.jfree.data KeyedObjects equals

List of usage examples for org.jfree.data KeyedObjects equals

Introduction

In this page you can find the example usage for org.jfree.data KeyedObjects equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Tests this object for equality with an arbitrary object.

Usage

From source file:org.jfree.data.KeyedObjectsTest.java

/**
 * Confirm special features of cloning./*from  w ww.j  av  a  2s  .  co m*/
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    // case 1 - object is mutable but not PublicCloneable
    Object obj1 = new ArrayList();
    KeyedObjects ko1 = new KeyedObjects();
    ko1.addObject("K1", obj1);
    KeyedObjects ko2 = (KeyedObjects) ko1.clone();
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));

    // the clone contains a reference to the original object
    assertTrue(ko2.getObject("K1") == obj1);

    // CASE 2 - object is mutable AND PublicCloneable
    obj1 = new DefaultPieDataset();
    ko1 = new KeyedObjects();
    ko1.addObject("K1", obj1);
    ko2 = (KeyedObjects) ko1.clone();
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));

    // the clone contains a reference to a CLONE of the original object
    assertTrue(ko2.getObject("K1") != obj1);
}

From source file:org.jfree.data.KeyedObjectsTest.java

/**
 * Confirm that cloning works./*w ww  . j  a v  a 2  s .c  o m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    KeyedObjects ko1 = new KeyedObjects();
    ko1.addObject("V1", new Integer(1));
    ko1.addObject("V2", null);
    ko1.addObject("V3", new Integer(3));
    KeyedObjects ko2 = (KeyedObjects) ko1.clone();
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));
}

From source file:org.jfree.data.junit.KeyedObjectsTests.java

/**
 * Confirm special features of cloning.//from  w ww.j av a  2  s .c  o m
 */
public void testCloning2() {
    // case 1 - object is mutable but not PublicCloneable
    Object obj1 = new ArrayList();
    KeyedObjects ko1 = new KeyedObjects();
    ko1.addObject("K1", obj1);
    KeyedObjects ko2 = null;
    try {
        ko2 = (KeyedObjects) ko1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));

    // the clone contains a reference to the original object
    assertTrue(ko2.getObject("K1") == obj1);

    // CASE 2 - object is mutable AND PublicCloneable
    obj1 = new DefaultPieDataset();
    ko1 = new KeyedObjects();
    ko1.addObject("K1", obj1);
    ko2 = null;
    try {
        ko2 = (KeyedObjects) ko1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));

    // the clone contains a reference to a CLONE of the original object
    assertTrue(ko2.getObject("K1") != obj1);
}

From source file:org.jfree.data.junit.KeyedObjectsTests.java

/**
 * Confirm that cloning works.// w w w.ja v  a  2 s.c  om
 */
public void testCloning() {
    KeyedObjects ko1 = new KeyedObjects();
    ko1.addObject("V1", new Integer(1));
    ko1.addObject("V2", null);
    ko1.addObject("V3", new Integer(3));
    KeyedObjects ko2 = null;
    try {
        ko2 = (KeyedObjects) ko1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));
}