Example usage for org.jfree.data KeyedObject getClass

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

Introduction

In this page you can find the example usage for org.jfree.data KeyedObject 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.KeyedObjectTest.java

/**
 * Confirm that cloning works.//from  w w  w. j ava  2  s. c  o m
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    KeyedObject ko1 = new KeyedObject("Test", "Object");
    KeyedObject ko2 = (KeyedObject) ko1.clone();
    assertTrue(ko1 != ko2);
    assertTrue(ko1.getClass() == ko2.getClass());
    assertTrue(ko1.equals(ko2));
}

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

/**
 * Confirm special features of cloning./*w w w. ja  va  2 s. c  om*/
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    // case 1 - object is mutable but not PublicCloneable
    Object obj1 = new ArrayList();
    KeyedObject ko1 = new KeyedObject("Test", obj1);
    KeyedObject ko2 = (KeyedObject) 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() == obj1);

    // CASE 2 - object is mutable AND PublicCloneable
    obj1 = new DefaultPieDataset();
    ko1 = new KeyedObject("Test", obj1);
    ko2 = (KeyedObject) 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() != obj1);
}