/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2021, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
 * Other names may be trademarks of their respective owners.]
 * 
 * ---------------
 * CloneUtils.java
 * ---------------
 * (C) Copyright 2014-2021, by Object Refinery Limited.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   -;
 *
 */
package org.jfree.chart.internal;

import org.jfree.chart.api.PublicCloneable;
import org.jfree.chart.internal.Args;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jfree.chart.util.Args;

/**
 * Utilities for cloning.
 * 
 * @since 1.0.18
 */
public class CloneUtils {
    
    /**
     * Returns a clone of the specified object, if it can be cloned, otherwise
     * throws a {@code CloneNotSupportedException}.  If the object is 
     * {@code null} this method returns {@code null}.
     *
     * @param object the object to clone ({@code null} permitted).
     * 
     * @param <T>  the object type.
     * 
     * @return A clone of the specified object, or {@code null}.
     * 
     * @throws CloneNotSupportedException if the object cannot be cloned.
     */
    public static <T> T clone(T object) throws CloneNotSupportedException {
        if (object == null) {
            return null;
        }
        if (object instanceof PublicCloneable) {
            PublicCloneable pc = (PublicCloneable) object;
            return (T) pc.clone();
        } else {
            try {
                Method method = object.getClass().getMethod("clone",
                        (Class[]) null);
                if (Modifier.isPublic(method.getModifiers())) {
                    return (T) method.invoke(object, (Object[]) null);
                }
            } catch (NoSuchMethodException e) {
                throw new CloneNotSupportedException("Object without clone() method is impossible.");
            } catch (IllegalAccessException e) {
                throw new CloneNotSupportedException("Object.clone(): unable to call method.");
            } catch (InvocationTargetException e) {
                throw new CloneNotSupportedException("Object without clone() method is impossible.");
            }
        }
        throw new CloneNotSupportedException("Failed to clone.");
    }

    /**
     * Returns a list containing cloned copies of the items in the source
     * list.
     * 
     * @param source  the source list ({@code null} not permitted).
     * 
     * @param <T>  the type of the list items.
     * 
     * @return A new list. 
     */
    public static <T> List<T>cloneList(List<T> source) {
        Args.nullNotPermitted(source, "source");
        List<T> result = new ArrayList<>();
        for (Object obj: source) {
            try {
                result.add((T) clone(obj));
            } catch (CloneNotSupportedException ex) {
                throw new RuntimeException(ex);
            }
        }
        return result;
    }
    
    /**
     * Returns a new map that contains the same keys and cloned copied of the
     * values from the source map.
     * 
     * @param source  the source map ({@code null} not permitted).
     * 
     * @param <K>  the type for the keys.
     * @param <V>  the type for the values.
     * 
     * @return A new map. 
     * 
     * @since 1.0.18
     */
    public static <K, V> Map<K, V> cloneMapValues(Map<K, V> source) {
        Args.nullNotPermitted(source, "source");
        Map<K, V> result = new HashMap<>();
        for (K key : source.keySet()) {
            V value = source.get(key);
            if (value != null) {
                try {
                    result.put(key, clone(value));
                } catch (CloneNotSupportedException ex) {
                    throw new RuntimeException(ex);
                }
            } else {
                result.put(key, null);
            }
        }
        return result;
    }
   
}

@@ -1514,46 +1514,8 @@
 le;%0A
-import org.jfree.chart.internal.Args;%0A
 impo
@@ -1732,42 +1732,8 @@
 Map;
-%0Aimport org.jfree.chart.util.Args;
 %0A%0A/*
@@ -1764,29 +1764,8 @@
 ng.%0A
- * %0A * @since 1.0.18%0A
  */%0A

Fix compile error.