// Path: src/main/java/com/github/trang/copiers/util/Preconditions.java
// public static void checkNotNull(Object o, String msg) {
//     if (o == null) {
//         throw new NullPointerException(msg);
//     }
// }
// 
// Path: src/main/java/com/github/trang/copiers/base/Copier.java
// public interface Copier<F, T> extends BeanCopier<F, T>, ArrayCopier<F, T>, ListCopier<F, T>, SetCopier<F, T> {
// 
// }
// 
// Path: src/main/java/com/github/trang/copiers/exception/CopierException.java
// public class CopierException extends RuntimeException {
// 
//     public CopierException() {
//         super();
//     }
// 
//     public CopierException(String message) {
//         super(message);
//     }
// 
//     public CopierException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public CopierException(Throwable cause) {
//         super(cause);
//     }
// 
//     public CopierException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


import static com.github.trang.copiers.util.Preconditions.checkNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import com.github.trang.copiers.base.Copier;
import com.github.trang.copiers.exception.CopierException;
import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.beans.BeanMap;
package com.github.trang.copiers.cglib;





/**
 * JavaBean 转换为 Map
 *
 * @author trang
 */
@Slf4j(topic = "copiers")
public class BeanToMapCopier<F> implements Copier<F, Map<String, Object>> {

    @Override
    public Map<String, Object> copy(F bean) {
        return copy(bean, HashMap::new);
    }

    @SuppressWarnings("unchecked")
    public Map<String, Object> copy(F bean, Supplier<Map<String, Object>> mapFactory) {
        checkNotNull(bean, "source bean cannot be null!");
        checkNotNull(mapFactory, "map factory cannot be null!");
        try {
            BeanMap beanMap = BeanMap.create(bean);
            Map<String, Object> map = mapFactory.get();
            map.putAll(beanMap);
            return map;
// Path: src/main/java/com/github/trang/copiers/util/Preconditions.java
// public static void checkNotNull(Object o, String msg) {
//     if (o == null) {
//         throw new NullPointerException(msg);
//     }
// }
// 
// Path: src/main/java/com/github/trang/copiers/base/Copier.java
// public interface Copier<F, T> extends BeanCopier<F, T>, ArrayCopier<F, T>, ListCopier<F, T>, SetCopier<F, T> {
// 
// }
// 
// Path: src/main/java/com/github/trang/copiers/exception/CopierException.java
// public class CopierException extends RuntimeException {
// 
//     public CopierException() {
//         super();
//     }
// 
//     public CopierException(String message) {
//         super(message);
//     }
// 
//     public CopierException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public CopierException(Throwable cause) {
//         super(cause);
//     }
// 
//     public CopierException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


// Path: src/main/java/com/github/trang/copiers/cglib/BeanToMapCopier.java
import static com.github.trang.copiers.util.Preconditions.checkNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import com.github.trang.copiers.base.Copier;
import com.github.trang.copiers.exception.CopierException;
import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.beans.BeanMap;

package com.github.trang.copiers.cglib;





/**
 * JavaBean 转换为 Map
 *
 * @author trang
 */
@Slf4j(topic = "copiers")
public class BeanToMapCopier<F> implements Copier<F, Map<String, Object>> {

    @Override
    public Map<String, Object> copy(F bean) {
        return copy(bean, HashMap::new);
    }

    @SuppressWarnings("unchecked")
    public Map<String, Object> copy(F bean, Supplier<Map<String, Object>> mapFactory) {
        checkNotNull(bean, "source bean cannot be null!");
        checkNotNull(mapFactory, "map factory cannot be null!");
        try {
            BeanMap beanMap = BeanMap.create(bean);
            Map<String, Object> map = mapFactory.get();
            map.putAll(beanMap);
            return map;
        } catch (Exception e) {