Example usage for org.jfree.data KeyedObjects getClass

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

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

/**
 * Confirm special features of cloning./*ww  w  . j a v a  2s  . com*/
 */
@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.//from ww w  .  j  a va2  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.//  w  w  w.ja va2  s  .c  om
 */
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.//from   w w  w . j a  v  a 2 s. c  o m
 */
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));
}