WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package tech.powerjob.remote.framework.utils;
 
import org.apache.commons.lang3.ArrayUtils;
import tech.powerjob.common.PowerSerializable;
 
import java.util.Optional;
 
/**
 * RemoteUtils
 *
 * @author tjq
 * @since 2023/1/1
 */
public class RemoteUtils {
 
    public static Optional<Class<?>> findPowerSerialize(Class<?>[] parameterTypes) {
 
        if (ArrayUtils.isEmpty(parameterTypes)) {
            return Optional.empty();
        }
 
        for (Class<?> clz : parameterTypes) {
            final Class<?>[] interfaces = clz.getInterfaces();
            if (ArrayUtils.isEmpty(interfaces)) {
                continue;
            }
 
            if (PowerSerializable.class.isAssignableFrom(clz)) {
                return Optional.of(clz);
            }
        }
        return Optional.empty();
    }
 
}