package com.ysu.zyw.tc.base.utils;

import com.fasterxml.jackson.core.type.TypeReference;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Map;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * TcBeanUtils defines bean related operations
 *
 * @author yaowu.zhang
 */
@Slf4j
@UtilityClass
public class TcBeanUtils {

    public static <T> T copyProperties(@Nonnull Object source, @Nonnull T target) {
        checkNotNull(source);
        checkNotNull(target);
        checkArgument(!(source instanceof Map) && !(target instanceof Map));
        BeanUtils.copyProperties(source, target);
        return target;
    }

    public static <T> T[] copyProperties(@Nonnull Object source, @Nonnull T... targets) {
        checkNotNull(source);
        checkNotNull(targets);
        Arrays.stream(targets).forEach(target -> BeanUtils.copyProperties(source, target));
        return targets;
    }

    public static <T> T deepCopyProperties(@Nonnull Object source, @Nonnull TypeReference<T> typeReference) {
        checkNotNull(source);
        checkNotNull(typeReference);
        return TcSerializationUtils.readJson(TcSerializationUtils.writeJson(source), typeReference);
    }

}

@@ -253,22 +253,20 @@
 va.util.
-Arrays
+List
 ;%0Aimport
@@ -871,11 +871,15 @@
 %3CT%3E 
-T%5B%5D
+List%3CT%3E
  cop
@@ -927,12 +927,15 @@
 ull 
-T...
+List%3CT%3E
  tar
@@ -1015,30 +1015,15 @@
     
-Arrays.stream(
 targets
-)
 .for

optimize bean utils array parameter to list