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


Java Paranamer类代码示例

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


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

示例1: CodeGeneratorMethod

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public CodeGeneratorMethod(Method m) {
    this.underlyingMethod = m;
    this.methodName = m.getName();
    this.returnType = m.getReturnType();
//    Paranamer para = new BytecodeReadingParanamer();
    Paranamer para = new AnnotationParanamer();
    String[] parameterNames = para.lookupParameterNames(m, true);
    if (parameterNames == null) {
      throw new RuntimeException(String.format("Unable to read the parameter names for method %s.  This is likely due to the class files not including the appropriate debugging information.  Look up java -g for more information.", m));
    }
    Class<?>[] types = m.getParameterTypes();
    if (parameterNames.length != types.length) {
      throw new RuntimeException(String.format("Unexpected number of parameter names %s.  Expected %s on method %s.", Arrays.toString(parameterNames), Arrays.toString(types), m.toGenericString()));
    }
    arguments = new CodeGeneratorArgument[parameterNames.length];
    for (int i = 0 ; i < parameterNames.length; i++) {
      arguments[i] = new CodeGeneratorArgument(parameterNames[i], types[i]);
    }
    exs = m.getExceptionTypes();
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:CodeGeneratorMethod.java

示例2: signature

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
/**
 * Extract {@link MBeanParameterInfo} signature for given method.
 */
private MBeanParameterInfo[] signature(final Method method) {
  // NOTE: when NX is based on Java8 we can replace Paranamer usage with JDK api
  Paranamer paranamer = new BytecodeReadingParanamer();
  String[] names = paranamer.lookupParameterNames(method);
  Class[] types = method.getParameterTypes();
  Annotation[][] annotations = method.getParameterAnnotations();

  MBeanParameterInfo[] result = new MBeanParameterInfo[names.length];
  for (int i=0; i< names.length; i++) {
    Descriptor descriptor = DescriptorHelper.build(annotations[i]);
    String description = DescriptorHelper.stringValue(descriptor, "description");

    result[i] = new MBeanParameterInfo(
        names[i],
        types[i].getName(),
        description,
        descriptor
    );
  }

  return result;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:26,代码来源:ReflectionMBeanOperation.java

示例3: shouldNotAllowModificationOfConfigurationElements

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
@Test
public void shouldNotAllowModificationOfConfigurationElements() throws NoSuchMethodException,
        IllegalAccessException {
    Configuration delegate = new MostUsefulConfiguration();
    Configuration unmodifiable = new UnmodifiableConfiguration(delegate);
    assertThatNotAllowed(unmodifiable, "useKeywords", Keywords.class);
    assertThatNotAllowed(unmodifiable, "doDryRun", Boolean.class);
    assertThatNotAllowed(unmodifiable, "useStoryControls", StoryControls.class);
    assertThatNotAllowed(unmodifiable, "useStoryLoader", StoryLoader.class);
    assertThatNotAllowed(unmodifiable, "useStoryParser", StoryParser.class);
    assertThatNotAllowed(unmodifiable, "useDefaultStoryReporter", StoryReporter.class);
    assertThatNotAllowed(unmodifiable, "useStoryReporterBuilder", StoryReporterBuilder.class);
    assertThatNotAllowed(unmodifiable, "useStoryPathResolver", StoryPathResolver.class);
    assertThatNotAllowed(unmodifiable, "useFailureStrategy", FailureStrategy.class);
    assertThatNotAllowed(unmodifiable, "usePendingStepStrategy", PendingStepStrategy.class);
    assertThatNotAllowed(unmodifiable, "useParanamer", Paranamer.class);
    assertThatNotAllowed(unmodifiable, "useParameterConverters", ParameterConverters.class);
    assertThatNotAllowed(unmodifiable, "useParameterControls", ParameterControls.class);
    assertThatNotAllowed(unmodifiable, "useStepCollector", StepCollector.class);
    assertThatNotAllowed(unmodifiable, "useStepMonitor", StepMonitor.class);
    assertThatNotAllowed(unmodifiable, "useStepPatternParser", StepPatternParser.class);
    assertThatNotAllowed(unmodifiable, "useViewGenerator", ViewGenerator.class);
    assertThatNotAllowed(unmodifiable, "useStoryPathResolver", StoryPathResolver.class);
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:25,代码来源:UnmodifiableConfigurationBehaviour.java

示例4: generate

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
@Test
public void generate() {
    Class<SakaiPortalLogin> clazz = SakaiPortalLogin.class;
    for (Method method : clazz.getMethods()) {
        if (!method.getDeclaringClass().getName().equals(clazz.getName())) {
            continue;
        }
        log.info("@WebMethod");
        log.info("@Path(\"/" + method.getName() + "\")");
        log.info("@Produces(\"text/plain\")");
        log.info("@GET");
        log.info("public " + method.getReturnType().getSimpleName() + " " + method.getName() + "(");
        Paranamer paranamer = new BytecodeReadingParanamer();

        try {
            String[] parameterNames = paranamer.lookupParameterNames(method);


            Class<?>[] types = method.getParameterTypes();
            int i = 0;
            for (String name : parameterNames) {
                log.info("@WebParam(name = \"" + name + "\", partName = \"" + name + "\") @QueryParam(\"" + name + "\") " + types[i].getSimpleName() + " " + name);
                if (i + 1 != parameterNames.length) {
                    log.info(",");
                } else {
                    log.info(") {\n");
                }
                i++;
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:36,代码来源:MethodGenerator.java

示例5: createErrorController

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
protected HttpHandler createErrorController(String error , Class<?> clazz , Class defaultClass){
  clazz = clazz == null ? defaultClass : clazz;
  ControllerMapping controllerMapping = new ControllerMapping( error , error);
  controllerMapping.setControllerClass( clazz );
  try {
    Method handlerError = clazz.getMethod("handleError", OvertownRequest.class);
    PathMapping methodMapping = new PathMapping( error , null , handlerError , getTemplate(handlerError) , handlerError.getAnnotation(JSONResponse.class) != null );
    Paranamer paranamer = new CachingParanamer(new BytecodeReadingParanamer());
    return new MainHttpHandler( controllerMapping , methodMapping , paranamer.lookupParameterNames( handlerError ) );
  } catch (NoSuchMethodException e) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:15,代码来源:StartupHandlerImpl.java

示例6: getMethodParamName

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public static String getMethodParamName(Method method, int i) {
    Paranamer pn = new BytecodeReadingParanamer();
    method.setAccessible(true);
    try { 
        String[] paramNames = pn.lookupParameterNames(method, true);
        return paramNames[i];
    } catch (Exception e) {
        return "@arg(" + i + ")";
    }
}
 
开发者ID:aleksandarmilicevic,项目名称:squander,代码行数:11,代码来源:Utils.java

示例7: MethodInvoker

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public MethodInvoker(Method method, ParameterConverters parameterConverters, Paranamer paranamer, Meta meta) {
    this.method = method;
    this.parameterConverters = parameterConverters;
    this.paranamer = paranamer;
    this.meta = meta;
    this.methodArity = method.getParameterTypes().length;
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:8,代码来源:StepCreator.java

示例8: buildConfiguration

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
/**
 * Builds a Configuration instance based on annotation {@link Configure}
 * found in the annotated object instance
 * 
 * @return A Configuration instance
 */
public Configuration buildConfiguration() throws AnnotationRequired {

    if (!finder.isAnnotationPresent(Configure.class)) {
        // not using annotation configuration, default to most useful
        // configuration
        return new MostUsefulConfiguration();
    }

    Configuration configuration = configurationElement(finder, "using", Configuration.class);
    configuration.useKeywords(configurationElement(finder, "keywords", Keywords.class));
    configuration.useFailureStrategy(configurationElement(finder, "failureStrategy", FailureStrategy.class));
    configuration.usePendingStepStrategy(configurationElement(finder, "pendingStepStrategy",
            PendingStepStrategy.class));
    configuration.useParanamer(configurationElement(finder, "paranamer", Paranamer.class));
    configuration.useStoryControls(configurationElement(finder, "storyControls", StoryControls.class));
    configuration.useStepCollector(configurationElement(finder, "stepCollector", StepCollector.class));
    configuration.useStepdocReporter(configurationElement(finder, "stepdocReporter", StepdocReporter.class));
    configuration.useStepFinder(configurationElement(finder, "stepFinder", StepFinder.class));
    configuration.useStepMonitor(configurationElement(finder, "stepMonitor", StepMonitor.class));
    configuration.useStepPatternParser(configurationElement(finder, "stepPatternParser", StepPatternParser.class));
    configuration.useStoryLoader(configurationElement(finder, "storyLoader", StoryLoader.class));
    configuration.useStoryParser(configurationElement(finder, "storyParser", StoryParser.class));
    configuration.useStoryPathResolver(configurationElement(finder, "storyPathResolver", StoryPathResolver.class));
    configuration
            .useDefaultStoryReporter(configurationElement(finder, "defaultStoryReporter", StoryReporter.class));
    configuration.useStoryReporterBuilder(configurationElement(finder, "storyReporterBuilder",
            StoryReporterBuilder.class));
    configuration.useViewGenerator(configurationElement(finder, "viewGenerator", ViewGenerator.class));
    configuration.useParameterConverters(parameterConverters(finder));
    configuration.useParameterControls(configurationElement(finder, "parameterControls", ParameterControls.class));
    configuration.usePathCalculator(configurationElement(finder, "pathCalculator", PathCalculator.class));
    return configuration;
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:40,代码来源:AnnotationBuilder.java

示例9: getName

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public String getName() {
    Param param = getAnnotation(Param.class);
    if (param != null) {
        return param.value();
    }
    if (parameter.isNamePresent()) {
        return parameter.getName();
    }
    Paranamer paranamer = getTypeDescriptors().getParanamer();
    String[] names = paranamer.lookupParameterNames(getAccessibleObject());
    return names.length > index ? names[index] : "arg" + index;
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:13,代码来源:ParameterDescriptor.java

示例10: AopAwareParanamerParameterNameProvider

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public AopAwareParanamerParameterNameProvider(final Paranamer paranamer) {
  super(paranamer);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:4,代码来源:AopAwareParanamerParameterNameProvider.java

示例11: ParameterNameResolverParanamerImpl

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public ParameterNameResolverParanamerImpl(final Paranamer paranamer) {
    this.paranamer = paranamer;
}
 
开发者ID:sebthom,项目名称:oval,代码行数:4,代码来源:ParameterNameResolverParanamerImpl.java

示例12: build

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public MBeanOperation build()
{
    if (target == null) {
        throw new IllegalArgumentException("JmxOperation must have a target object");
    }

    // We must have a method to invoke
    if (concreteMethod == null) {
        throw new IllegalArgumentException("JmxOperation must have a concrete method");
    }

    String operationName = name;
    if (operationName == null) {
        operationName = concreteMethod.getName();
    }

    //
    // Build Parameter Infos
    // Extract parameter names from debug symbols
    Paranamer paranamer = new BytecodeReadingParanamer();
    String[] parameterNames = paranamer.lookupParameterNames(concreteMethod);
    Class<?>[] types = concreteMethod.getParameterTypes();

    // Parameter annotations used form descriptor come from the annotated method, not the public method
    Annotation[][] parameterAnnotations;
    if (annotatedMethod != null) {
        parameterAnnotations = annotatedMethod.getParameterAnnotations();
    }
    else {
        parameterAnnotations = new Annotation[annotatedMethod.getParameterTypes().length][];
    }

    MBeanParameterInfo[] parameterInfos = new MBeanParameterInfo[parameterNames.length];
    for (int i = 0; i < parameterNames.length; ++i) {
        // Parameter Descriptor
        Descriptor parameterDescriptor = AnnotationUtils.buildDescriptor(parameterAnnotations[i]);
        // Parameter Description
        String parameterDescription = AnnotationUtils.getDescription(parameterDescriptor, parameterAnnotations[i]);

        parameterInfos[i] = new MBeanParameterInfo(
                parameterNames[i],
                types[i].getName(),
                parameterDescription,
                parameterDescriptor);
    }

    // Descriptor
    Descriptor descriptor = null;
    if (annotatedMethod != null) {
        descriptor = AnnotationUtils.buildDescriptor(annotatedMethod);
    }

    // Description
    String description = AnnotationUtils.getDescription(descriptor, annotatedMethod);

    MBeanOperationInfo mbeanOperationInfo = new MBeanOperationInfo(
            operationName,
            description,
            parameterInfos,
            concreteMethod.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN,
            descriptor);

    return new ReflectionMBeanOperation(mbeanOperationInfo, target, concreteMethod);
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:66,代码来源:MBeanOperationBuilder.java

示例13: create

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
@Override
public Paranamer create() {
	return new AdaptiveParanamer(new DefaultParanamer(), new BytecodeReadingParanamer(),new NamedAnnotationParanamer());
}
 
开发者ID:Cybernostics,项目名称:nanorest,代码行数:5,代码来源:InterfaceParserUtil.java

示例14: ViewParamsMerger

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
public ViewParamsMerger(Paranamer paranamer) {
    super();
    this.paranamer = paranamer;
}
 
开发者ID:rwitzel,项目名称:CouchRepository,代码行数:5,代码来源:ViewParamsMerger.java

示例15: initialMethod

import com.thoughtworks.paranamer.Paranamer; //导入依赖的package包/类
/**
 * 初始化 方法参数定义
 */
private void initialMethod() {
	isvoid = method.getReturnType().getName().equals("void");
	if (method.getParameterTypes().length == 0) {
		return;
	}
	methodParamMap = new LinkedHashMap<String, MethodParam>();
	methodParamList = new ArrayList<MethodParam>();
	Paranamer paranamer = new BytecodeReadingParanamer();
	String[] parameterNames = paranamer.lookupParameterNames(method);
	Annotation[][] pas = method.getParameterAnnotations();
	int i = 0;
	for (Class<?> typeClass : method.getParameterTypes()) {
		MethodParam mp = new MethodParam();
		String name = parameterNames[i];

		Convert convert = CONVERT_MAP.get(typeClass);
		if (typeClass.equals(BModelMap.class)) {
			if (modelMapParamIndex != null) {
				logger.error("view block only set one BModelMap");
			}
			modelMapParamIndex = i;
		} else if (convert == null) {
			convert = CONVERT_MAP.get(BRequestParam.class);
			for (Annotation a : pas[i]) {
				if (a.annotationType().equals(BRequestParam.class)) {
					BRequestParam p = (BRequestParam) a;
					boolean required = false;
					Object defValue = null;
					// RequestParam 注解
					if (p != null) {
						if (!"".equals(p.value())) {
							name = p.value();
						}
						if (!p.defaultValue().equals(ValueConstants.DEFAULT_NONE)) {
							if (ConvertUtils.lookup(typeClass) != null) {
								defValue = ConvertUtils.convert(p.defaultValue(), typeClass);
							}
						}
						required = p.required();
					}

					// others param
					mp.setRequired(required);
					mp.setDefValue(defValue);
					break;
				} else if (a.annotationType().equals(BModelAttribute.class)) {
					mp.setModelAttribute(true);
					break;
				}
			}
		}
		mp.setName(name);
		mp.setIndex(i);
		mp.setConvert(convert);
		mp.setTypeClass(typeClass);
		methodParamMap.put(mp.getName(), mp);
		methodParamList.add(mp);
		i++;
	}
}
 
开发者ID:liyiorg,项目名称:viewblock,代码行数:64,代码来源:ViewblockObject.java


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