當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。