All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.datalking.common.PrioritizedParameterNameDiscoverer Maven / Gradle / Ivy

The newest version!
package com.github.datalking.common;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;

/**
 * 优先找到方法参数名不为空的类
 *
 * @author yaoo on 4/19/18
 */
public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscoverer {

    private final List parameterNameDiscoverers = new LinkedList<>();

    public void addDiscoverer(ParameterNameDiscoverer pnd) {
        this.parameterNameDiscoverers.add(pnd);
    }

    @Override
    public String[] getParameterNames(Method method) {
        for (ParameterNameDiscoverer pnd : this.parameterNameDiscoverers) {
            String[] result = pnd.getParameterNames(method);

            if (result != null) {
                return result;
            }
        }
        return null;
    }

    @Override
    public String[] getParameterNames(Constructor ctor) {
        for (ParameterNameDiscoverer pnd : this.parameterNameDiscoverers) {
            String[] result = pnd.getParameterNames(ctor);

            if (result != null) {
                return result;
            }
        }
        return null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy