Example usage for org.jfree.data DefaultKeyedValues clone

List of usage examples for org.jfree.data DefaultKeyedValues clone

Introduction

In this page you can find the example usage for org.jfree.data DefaultKeyedValues clone.

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Returns a clone.

Usage

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

/**
 * Some checks for the clone() method./* w w  w.  jav  a 2 s.c o  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    v1.addValue("V1", new Integer(1));
    v1.addValue("V2", null);
    v1.addValue("V3", new Integer(3));
    DefaultKeyedValues v2 = (DefaultKeyedValues) v1.clone();
    assertTrue(v1 != v2);
    assertTrue(v1.getClass() == v2.getClass());
    assertTrue(v1.equals(v2));

    // confirm that the clone is independent of the original
    v2.setValue("V1", new Integer(44));
    assertFalse(v1.equals(v2));
}

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

/**
 * Some checks for the clone() method./*from   w  ww. j a  v  a  2 s  .  co m*/
 */
public void testCloning() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    v1.addValue("V1", new Integer(1));
    v1.addValue("V2", null);
    v1.addValue("V3", new Integer(3));
    DefaultKeyedValues v2 = null;
    try {
        v2 = (DefaultKeyedValues) v1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(v1 != v2);
    assertTrue(v1.getClass() == v2.getClass());
    assertTrue(v1.equals(v2));

    // confirm that the clone is independent of the original
    v2.setValue("V1", new Integer(44));
    assertFalse(v1.equals(v2));
}

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

/**
 * Some checks for the clone() method./*  w  w w .j a  v  a  2  s  .c  om*/
 */
public void testCloning() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    v1.addValue("V1", new Integer(1));
    v1.addValue("V2", null);
    v1.addValue("V3", new Integer(3));
    DefaultKeyedValues v2 = null;
    try {
        v2 = (DefaultKeyedValues) v1.clone();
    } catch (CloneNotSupportedException e) {
        System.err.println("Failed to clone.");
    }
    assertTrue(v1 != v2);
    assertTrue(v1.getClass() == v2.getClass());
    assertTrue(v1.equals(v2));

    // confirm that the clone is independent of the original
    v2.setValue("V1", new Integer(44));
    assertFalse(v1.equals(v2));
}