当前位置: 首页>>代码示例>>Java>>正文


Java Method.toGenericString方法代码示例

本文整理汇总了Java中java.lang.reflect.Method.toGenericString方法的典型用法代码示例。如果您正苦于以下问题:Java Method.toGenericString方法的具体用法?Java Method.toGenericString怎么用?Java Method.toGenericString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Method的用法示例。


在下文中一共展示了Method.toGenericString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isOverriedMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
static boolean isOverriedMethod(Object currentObject, String methodName, String method, Class... clazzs) {
    LogUtils.i(TAG, "  methodName:" + methodName + "   method:" + method);
    boolean tag = false;
    if (currentObject == null)
        return tag;
    try {
        Class clazz = currentObject.getClass();
        Method mMethod = clazz.getMethod(methodName, clazzs);
        String gStr = mMethod.toGenericString();
        tag = !gStr.contains(method);
    } catch (Exception igonre) {
        if (LogUtils.isDebug()) {
            igonre.printStackTrace();
        }
    }

    LogUtils.i(TAG, "isOverriedMethod:" + tag);
    return tag;
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:20,代码来源:AgentWebUtils.java

示例2: isOverriedMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static boolean isOverriedMethod(Object currentObject, String methodName, String method, Class... clazzs) {
    LogUtils.i("Info", "currentObject:" + currentObject + "  methodName:" + methodName + "   method:" + method);
    boolean tag = false;
    if (currentObject == null)
        return tag;

    try {

        Class clazz = currentObject.getClass();
        Method mMethod = clazz.getMethod(methodName, clazzs);
        String gStr = mMethod.toGenericString();


        tag = !gStr.contains(method);
    } catch (Exception igonre) {
        igonre.printStackTrace();
    }

    LogUtils.i("Info", "isOverriedMethod:" + tag);
    return tag;
}
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:22,代码来源:AgentWebX5Utils.java

示例3: checkAsyncInterface

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void checkAsyncInterface() {
    for (Method m : asyncRequestHandlerClass.getMethods()) {
        try {
            if (!m.getReturnType().isAssignableFrom(CompletableFuture.class) || m.getReturnType().equals(Object.class)) {
                throw new IllegalArgumentException("All methods of async request handler must return CompletableFuture. "
                        + "Offending method: "+m.toGenericString());
            }
            //CompletableFuture<T>
            Class<?> targetType = (Class<?>)((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments()[0];
            Method originalMethod = requestHandlerClass.getMethod(m.getName(), m.getParameterTypes());
            if (originalMethod.getReturnType().equals(void.class) ? !targetType.equals(Void.class) // more primitive handling needed
                    : !targetType.isAssignableFrom(originalMethod.getReturnType())) {
                throw new IllegalArgumentException("Return type is not compatible for "+m.toGenericString()+
                        ". Original method returns "+originalMethod.getGenericReturnType().getTypeName());
            }
            mapping.put(m, originalMethod);
        } catch (NoSuchMethodException | SecurityException ex) {
            throw new IllegalStateException("Cannot inspect request handler classes", ex);
        }
    }
}
 
开发者ID:goodees,项目名称:goodees,代码行数:22,代码来源:ProxiedSyncEventSourcingRuntime.java

示例4: register

import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
 * Registers a new listener.
 *
 * @param listener The listener to register
 */
public void register(Object listener) {
    if(listener == null) throw new NullPointerException("listener");
    Class<?> listenerClass = listener.getClass();
    if(Modifier.isPublic(listenerClass.getModifiers())) {
        for(ASMEventHandler h : handlers(listener)) {
            getHandlers(h.getEventClass(), Listener.Priority.MEDIUM).add(new Pair<>(listener, h));
        }
    } else {//Cannot access the class, reflection is the only option
        for(Method m : listenerClass.getMethods()) {
            Listener list = m.getAnnotation(Listener.class);
            if(list == null) continue;
            Class<?>[] params = m.getParameterTypes();
            if(params.length != 1)
                throw new IllegalArgumentException("parameterTypes.length != 1: " + m.toGenericString());
            getHandlers(params[0], Listener.Priority.MEDIUM).add(new Pair<>(listener, new ReflectionEventHandler(listener, m)));
        }
    }
}
 
开发者ID:BRjDevs,项目名称:BRjLibs,代码行数:24,代码来源:EventBus.java

示例5: setSetField

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void setSetField(Object newVO, Object oldVO, Method method)
        throws IllegalAccessException, InvocationTargetException,
        ClassNotFoundException, NoSuchMethodException {
    String className = method.toGenericString();
    className = className.substring(className.indexOf('<') + 1,
            className.indexOf('>'));
    final Set<?> set = convertSet((Set<?>) method.invoke(oldVO),
            Class.forName(getNewClassName(Class.forName(className))));
    newVO.getClass().getMethod(getSetter(method), method.getReturnType())
            .invoke(newVO, set);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:12,代码来源:AbstractVOConverter.java

示例6: setListField

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void setListField(Object newVO, Object oldVO, Method method)
        throws IllegalAccessException, InvocationTargetException,
        NoSuchMethodException, ClassNotFoundException {
    String className = method.toGenericString();
    className = className.substring(className.indexOf('<') + 1,
            className.indexOf('>'));
    final List<?> list = convertList((List<?>) method.invoke(oldVO),
            Class.forName(getNewClassName(Class.forName(className))));
    newVO.getClass().getMethod(getSetter(method), method.getReturnType())
            .invoke(newVO, list);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:12,代码来源:AbstractVOConverter.java

示例7: getParamMap

import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
 * 获取注解参数
 * 
 * @param method
 * @param args
 * @return
 */
@SuppressWarnings("unchecked")
private Map<String, Object> getParamMap(Method method, Object[] args) {
    Map<String, Object> paramMap = new HashMap<>();
    if (args == null) {
        return paramMap;
    }
    Annotation[][] parameterAnnotations = method.getParameterAnnotations();
    if ((parameterAnnotations == null || parameterAnnotations.length < args.length) && args.length > 0) {
        throw new JkException(this.getMapperInterface().getName() + "@Param is missing");
    }
    for (int i = 0; i < args.length; i++) {
        Object arg = args[i];
        Annotation[] as = parameterAnnotations[i];
        if (as.length == 0) {
            throw new JkException(method.toGenericString() + " @Param not find ");
        }
        if (arg instanceof Map) {
            Map<String, Object> mmp = (Map<String, Object>) arg;
            for (Entry<String, Object> entry : mmp.entrySet()) {
                Object val = entry.getValue();
                if (val instanceof String) {
                    // 转移sql防注入
                    entry.setValue(SqlUtils.escapeSql((String) val));
                }
            }
            paramMap.putAll(mmp);
        }
        // 转移sql防注入
        if (arg instanceof String) {
            arg = SqlUtils.escapeSql((String) arg);
        }
        Param param = (Param) as[0];
        paramMap.put(param.value(), arg);
    }
    return paramMap;
}
 
开发者ID:lftao,项目名称:jkami,代码行数:44,代码来源:MapperProxy.java

示例8: getPathUrl

import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
 * Url获取函数,作为函数传入StorageService。
 * @param path
 * @return FileInfo
 */
public static String getPathUrl(Path path) {
    String resourcePath = path.getName(0).relativize(path).toString().replace("\\", "/");
    String methodName = path.toFile().isDirectory() ? "viewDir" : "serveFile";
    Method method;
    try {
        method = FileServerEndpoint.class.getDeclaredMethod(methodName, HttpServletRequest.class);
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException("No " + methodName + " method in " + FileServerEndpoint.class.getSimpleName());
    }

    String methodPath;
    RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);

    if (requestMapping == null) {
        throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
    }
    String[] paths = requestMapping.path();
    if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
        methodPath = "/";
    }else {
        methodPath = paths[0].substring(0, paths[0].length() - 2);
    }

    String baseUrl = MvcUriComponentsBuilder
            .fromController(FileServerEndpoint.class)
            .build().toString();

    String pathUrl = baseUrl + methodPath + resourcePath;

    return pathUrl;
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:37,代码来源:FileServerUtil.java

示例9: set

import java.lang.reflect.Method; //导入方法依赖的package包/类
void set(Method method) {
    if (method == null) {
        this.signature = null;
        this.methodRef = null;
        this.typeRef = null;
    }
    else {
        this.signature = method.toGenericString();
        this.methodRef = new SoftReference<>(method);
        this.typeRef = new WeakReference<Class<?>>(method.getDeclaringClass());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:MethodRef.java

示例10: judgeDownloader

import java.lang.reflect.Method; //导入方法依赖的package包/类
private void judgeDownloader(Class<? extends AbstractAutoProcessModel> aClass) {
    Method[] methods = aClass.getMethods();
    for (final Method method : methods) {
        if (method.getAnnotation(DownLoadMethod.class) == null) {
            continue;
        }
        Preconditions.checkArgument(String.class.isAssignableFrom(method.getReturnType()));
        Preconditions.checkArgument(method.getParameterTypes().length >= 2);
        Preconditions.checkArgument(method.getParameterTypes()[0].isAssignableFrom(Seed.class));
        Preconditions.checkArgument(method.getParameterTypes()[1].isAssignableFrom(CrawlerSession.class));

        downloader = new Downloader() {
            @Override
            public String download(Seed seed, AbstractAutoProcessModel model, CrawlerSession crawlerSession) {
                try {
                    return (String) method.invoke(model, seed, crawlerSession);
                } catch (Exception e) {
                    throw new RuntimeException("invoke download method :" + method.toGenericString() + " failed", e);
                }
            }
        };
        return;
    }

    downloader = new Downloader() {
        @Override
        public String download(Seed seed, AbstractAutoProcessModel model, CrawlerSession crawlerSession) {
            return crawlerSession.getCrawlerHttpClient().get(seed.getData());
        }
    };
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:32,代码来源:AnnotationSeedProcessor.java

示例11: Invocation

import java.lang.reflect.Method; //导入方法依赖的package包/类
public Invocation(Method methodName) {
    this.methodName = methodName.toGenericString();
}
 
开发者ID:AdamBien,项目名称:perceptor,代码行数:4,代码来源:Invocation.java


注:本文中的java.lang.reflect.Method.toGenericString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。