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


Java ParameterAnnotationsAttribute类代码示例

本文整理汇总了Java中javassist.bytecode.ParameterAnnotationsAttribute的典型用法代码示例。如果您正苦于以下问题:Java ParameterAnnotationsAttribute类的具体用法?Java ParameterAnnotationsAttribute怎么用?Java ParameterAnnotationsAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getParameterNames

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
private String[] getParameterNames(final CtBehavior behavior) throws NotFoundException {
    final MethodInfo methodInfo = behavior.getMethodInfo();
    final ParameterAnnotationsAttribute attribute =
            (ParameterAnnotationsAttribute) methodInfo.getAttribute(ParameterAnnotationsAttribute.visibleTag);
    if (attribute == null) {
        return null;
    }
    final int numParameters = behavior.getParameterTypes().length;
    final String[] parameterNames = new String[numParameters];
    final Annotation[][] annotationsArray = attribute.getAnnotations();
    if (annotationsArray == null || annotationsArray.length != numParameters) {
        return null;
    }
    for (int i = 0; i < numParameters; ++i) {
        final String parameterName = getParameterName(annotationsArray[i]);
        if (parameterName == null) {
            return null;
        }
        parameterNames[i] = parameterName;
    }
    return parameterNames;
}
 
开发者ID:lastaflute,项目名称:lasta-di,代码行数:23,代码来源:BeanDescImpl.java

示例2: addMethodAnnotationDependencies

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
private void addMethodAnnotationDependencies(CtClass ctClass, Collection<String> imports) {
    for (CtMethod ctMethod : ctClass.getDeclaredMethods()) {
        MethodInfo methodInfo = ctMethod.getMethodInfo2();
        List<?> attributes = methodInfo.getAttributes();
        addAnnotationsForAttributes(imports, attributes);
        addParameterAnnotationsFor(imports, methodInfo, ParameterAnnotationsAttribute.visibleTag);
        addParameterAnnotationsFor(imports, methodInfo, ParameterAnnotationsAttribute.invisibleTag);
    }
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:10,代码来源:JavaAssistClass.java

示例3: addParameterAnnotationsFor

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
private void addParameterAnnotationsFor(Collection<String> imports, MethodInfo methodInfo, String tag) {
    AttributeInfo attribute = methodInfo.getAttribute(tag);
    ParameterAnnotationsAttribute annotationAttribute = (ParameterAnnotationsAttribute) attribute;
    if (annotationAttribute != null) {
        Annotation[][] parameters = annotationAttribute.getAnnotations();
        for (Annotation[] annotations : parameters) {
            for (Annotation annotation : annotations) {
                imports.add(annotation.getTypeName());
            }
        }
    }
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:13,代码来源:JavaAssistClass.java

示例4: duplicateParameterAnnotationsAttribute

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
public static ParameterAnnotationsAttribute duplicateParameterAnnotationsAttribute(ConstPool cp, Method method) {
    ParameterAnnotationsAttribute oldAns = new ParameterAnnotationsAttribute(cp, ParameterAnnotationsAttribute.visibleTag);
    javassist.bytecode.annotation.Annotation[][] anAr = new javassist.bytecode.annotation.Annotation[method.getParameterAnnotations().length][];
    for (int i = 0; i < anAr.length; ++i) {
        anAr[i] = new javassist.bytecode.annotation.Annotation[method.getParameterAnnotations()[i].length];
        for (int j = 0; j < anAr[i].length; ++j) {
            anAr[i][j] = createJavassistAnnotation(method.getParameterAnnotations()[i][j], cp);
        }
    }
    oldAns.setAnnotations(anAr);
    return oldAns;
}
 
开发者ID:baihui212,项目名称:tsharding,代码行数:13,代码来源:MapperAnnotationEnhancer.java

示例5: copyParameters

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
protected void copyParameters(CtMethod ctMethod, Method method, ClassPool cp) throws NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, CannotCompileException {
	String[] parmNames = (method != null) ? parmDiscover.getParameterNames(method) : null;
		MethodInfo methodInfo = ctMethod.getMethodInfo();
	ParameterAnnotationsAttribute paramAtrributeInfo = 
			new ParameterAnnotationsAttribute(
					methodInfo.getConstPool(), 
					ParameterAnnotationsAttribute.visibleTag);
	
	Annotation[][] paramArrays = new Annotation[method.getParameterTypes().length][];
	java.lang.annotation.Annotation[][] parmAnnotations = method.getParameterAnnotations();
	int parmIndex = 0;
	for(Class<?> parm : method.getParameterTypes()) {
			
		// Clone the parameter Class
		//
		CtClass ctParm = cp.get(parm.getName());
		
		// Add the parameter to the method
		//
		ctMethod.addParameter(ctParm);
		
		// Add the Parameter Annotations to the Method
		//
		String parmName = (parmNames != null && parmNames.length > parmIndex) ? parmNames[parmIndex] : null;
		paramArrays[parmIndex] = createParameterAnnotations(
				parmName,
				ctMethod.getMethodInfo(),
				parmAnnotations[parmIndex],
				paramAtrributeInfo.getConstPool());
		parmIndex++;
	}
	paramAtrributeInfo.setAnnotations(paramArrays);
	methodInfo.addAttribute(paramAtrributeInfo);
}
 
开发者ID:statefulj,项目名称:statefulj,代码行数:35,代码来源:AbstractRestfulBinder.java

示例6: copyAnnotations

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
public static void copyAnnotations(MethodInfo from, MethodInfo to) {
    copyAttribute(from, to, AnnotationsAttribute.invisibleTag);
    copyAttribute(from, to, AnnotationsAttribute.visibleTag);
    copyAttribute(from, to, ParameterAnnotationsAttribute.invisibleTag);
    copyAttribute(from, to, ParameterAnnotationsAttribute.visibleTag);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:Javassists.java

示例7: addAssistedAnnotation

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
private void addAssistedAnnotation(ConstPool constPool, CtConstructor cc) {
    ParameterAnnotationsAttribute attribute = new ParameterAnnotationsAttribute(constPool,
            ParameterAnnotationsAttribute.visibleTag);
    attribute.setAnnotations(new Annotation[][]{{createAnnotation(constPool, Assisted.class)}});
    cc.getMethodInfo().addAttribute(attribute);
}
 
开发者ID:seedstack,项目名称:business,代码行数:7,代码来源:DefaultRepositoryGenerator.java

示例8: toParameterAnnotationsAttribute

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
private static ParameterAnnotationsAttribute toParameterAnnotationsAttribute(CtBehavior ctBehavior) {
    MethodInfo minfo = ctBehavior.getMethodInfo();
    ParameterAnnotationsAttribute attr = (ParameterAnnotationsAttribute) minfo
            .getAttribute(ParameterAnnotationsAttribute.visibleTag);
    return attr;
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:7,代码来源:Method.java

示例9: grabMethodandParameterAnnotation

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
public void grabMethodandParameterAnnotation(CtBehavior ctBehavior) {

        MethodInfo minfo = ctBehavior.getMethodInfo();
        AnnotationsAttribute methodattr = (AnnotationsAttribute) minfo
                .getAttribute(AnnotationsAttribute.visibleTag);

        if (methodattr != null) {
            Annotation[] methodAnn = methodattr.getAnnotations();

            for (Annotation object : methodAnn) {
                JavassistByteCodeStubBuilder.logger.debug("adding annotation " + object.getTypeName() +
                    " to " + ctBehavior.getLongName());
                methodAnnotation.add(object);
            }
        }

        // get parameter annotations

        ParameterAnnotationsAttribute attr = toParameterAnnotationsAttribute(ctBehavior);
        if (attr == null) {
            return;
        }

        javassist.bytecode.annotation.Annotation[][] parametersAnnotations = attr.getAnnotations();

        //        if (listMethodParameters.size() > 0) {

        for (int paramIndex = 0; paramIndex < parametersAnnotations.length; paramIndex++) {

            javassist.bytecode.annotation.Annotation[] paramAnnotations = parametersAnnotations[paramIndex];
            for (javassist.bytecode.annotation.Annotation parameterAnnotation : paramAnnotations) {

                MethodParameter mp = listMethodParameters.get(paramIndex);
                if (mp == null) {
                    mp = new MethodParameter();
                    listMethodParameters.set(paramIndex, mp);
                }
                JavassistByteCodeStubBuilder.logger.debug("adding annotation " +
                    parameterAnnotation.getTypeName() + " to param " + paramIndex + " of " +
                    ctBehavior.getLongName());
                mp.getAnnotations().add(parameterAnnotation);
            }
        }
    }
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:45,代码来源:Method.java

示例10: getAnnotationsForMethodParameter

import javassist.bytecode.ParameterAnnotationsAttribute; //导入依赖的package包/类
public static Annotation[] getAnnotationsForMethodParameter(MethodInfo methodInfo, int index) {

		ParameterAnnotationsAttribute visible = (ParameterAnnotationsAttribute) methodInfo.getAttribute(ParameterAnnotationsAttribute.visibleTag);
		ParameterAnnotationsAttribute invisible = (ParameterAnnotationsAttribute) methodInfo.getAttribute(ParameterAnnotationsAttribute.invisibleTag);

		Set<Annotation> retVal = new HashSet<Annotation>();

		retVal.addAll(findAnnotationsForAnnotationsArray(visible.getAnnotations()[index]));
		retVal.addAll(findAnnotationsForAnnotationsArray(invisible.getAnnotations()[index]));

		return retVal.toArray(new Annotation[retVal.size()]);
	}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:13,代码来源:JavassistAnnotationsHelper.java


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