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


Java JavaClass类代码示例

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


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

示例1: arrayRequiredAppearsInFieldJavadoc

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
@Test
public void arrayRequiredAppearsInFieldJavadoc() throws IOException {

    schemaRule.generateAndCompile("/schema/javaName/javaNameWithRequiredProperties.json", "com.example.required");
    File generatedJavaFileWithRequiredProperties = schemaRule.generated("com/example/required/JavaNameWithRequiredProperties.java");

    JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
    javaDocBuilder.addSource(generatedJavaFileWithRequiredProperties);

    JavaClass classWithRequiredProperties = javaDocBuilder.getClassByName("com.example.required.JavaNameWithRequiredProperties");

    JavaField javaFieldWithoutJavaName = classWithRequiredProperties.getFieldByName("requiredPropertyWithoutJavaName");
    JavaField javaFieldWithJavaName = classWithRequiredProperties.getFieldByName("requiredPropertyWithoutJavaName");

    assertThat(javaFieldWithoutJavaName.getComment(), containsString("(Required)"));
    assertThat(javaFieldWithJavaName.getComment(), containsString("(Required)"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JavaNameIT.java

示例2: inlineRequiredAppearsInFieldJavadoc

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
@Test
public void inlineRequiredAppearsInFieldJavadoc() throws IOException {

    schemaRule.generateAndCompile("/schema/javaName/javaNameWithRequiredProperties.json", "com.example.required");
    File generatedJavaFileWithRequiredProperties = schemaRule.generated("com/example/required/JavaNameWithRequiredProperties.java");

    JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
    javaDocBuilder.addSource(generatedJavaFileWithRequiredProperties);

    JavaClass classWithRequiredProperties = javaDocBuilder.getClassByName("com.example.required.JavaNameWithRequiredProperties");

    JavaField javaFieldWithoutJavaName = classWithRequiredProperties.getFieldByName("inlineRequiredPropertyWithoutJavaName");
    JavaField javaFieldWithJavaName = classWithRequiredProperties.getFieldByName("inlineRequiredPropertyWithoutJavaName");

    assertThat(javaFieldWithoutJavaName.getComment(), containsString("(Required)"));
    assertThat(javaFieldWithJavaName.getComment(), containsString("(Required)"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JavaNameIT.java

示例3: processAllMethods

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
private void processAllMethods(JavaClass javaClass, String resourcePath,
                               ObjectNode paths, ArrayNode tagArray, ObjectNode definitions) {
    // map of the path to its methods represented by an ObjectNode
    Map<String, ObjectNode> pathMap = new HashMap<>();

    javaClass.getMethods().forEach(javaMethod -> {
        javaMethod.getAnnotations().forEach(annotation -> {
            String name = annotation.getType().getName();
            if (name.equals(POST) || name.equals(GET) || name.equals(DELETE) || name.equals(PUT)) {
                // substring(12) removes "javax.ws.rs."
                String method = annotation.getType().toString().substring(12).toLowerCase();
                processRestMethod(javaMethod, method, pathMap, resourcePath, tagArray, definitions);
            }
        });
    });

    // for each path add its methods to the path node
    for (Map.Entry<String, ObjectNode> entry : pathMap.entrySet()) {
        paths.set(entry.getKey(), entry.getValue());
    }


}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OnosSwaggerMojo.java

示例4: getDomainMap

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
public Map<String, JavaClass> getDomainMap(final boolean forceRefresh) {
	if (isRefreshModel(forceRefresh)) {
		
		for (final String sourceTree : sourceTress) {
			javaDocBuilder.addSourceTree(new File(sourceTree));
		}
		
		final Searcher searcher = getRegexSearcher(regexFilter);
		final List<JavaClass> javaClasses = javaDocBuilder.search(searcher);
		
		for (final JavaClass javaClass : javaClasses) {
			try {
				this.fixQDoxAnnotations(javaClass);
			} catch (final ClassNotFoundException e) {
				throw new RuntimeException("Erro ao tentar ajustar os valores default de annotations", e);
			}
			
			domain.put(javaClass.getFullyQualifiedName(), javaClass);
		}
	}
	
	return domain;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:24,代码来源:DomainModelLoaderFactory.java

示例5: isGenerateRegex

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Verifica se as propriedades especificadas no map regexRules batem com as propriedades da JavaClass informada.
 * 
 * @param javaClass
 * @return
 */
protected boolean isGenerateRegex(JavaClass javaClass) {
	Set<String> keys = this.regexRules.keySet();
	// itera todas as chaves
	for (String keyProp : keys) {

		String jcPropValue;
		try {
			jcPropValue = BeanUtilsBean.getInstance().getProperty(javaClass, keyProp);
		} catch (Exception e) {
			// se a propriedade não existe sai do for
			break;
		}

		String regexRule = this.regexRules.get(keyProp);

		// se o valor encontrado é diferente do valor esperado não roda do template
		if (jcPropValue != null && !jcPropValue.matches(regexRule)) {
			log.warn(mf.format("rules.regexmap", this.template.getName(), javaClass.getName(), keyProp, jcPropValue, regexRule));
			return false;
		}
	}

	return true;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:31,代码来源:FreemarkerTemplateRules.java

示例6: isGenerateRegex

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Verifica se as propriedades especificadas no map regexRules batem com as propriedades da JavaClass informada.
 * 
 * @param javaClass
 * @return
 */
protected boolean isGenerateRegex(final JavaClass javaClass) {
	final Set<String> keys = this.regexRules.keySet();
	// itera todas as chaves
	for (final String keyProp : keys) {
		
		String jcPropValue;
		try {
			jcPropValue = BeanUtilsBean.getInstance().getProperty(javaClass, keyProp);
		} catch (final Exception e) {
			// se a propriedade não existe sai do for
			break;
		}
		
		final String regexRule = this.regexRules.get(keyProp);
		
		// se o valor encontrado é diferente do valor esperado não roda do template
		if (jcPropValue != null && !jcPropValue.matches(regexRule)) {
			this.log.warn(FreemarkerTemplateRules.mf.format("rules.regexmap", this.template.getName(), javaClass.getName(), keyProp,
					jcPropValue, regexRule));
			return false;
		}
	}
	
	return true;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:32,代码来源:FreemarkerTemplateRules.java

示例7: collectTestMethods

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
private static Sequence<TestMethod> collectTestMethods(Class aClass, Sequence<Method> methods) throws IOException {
    final Option<JavaClass> javaClass = getJavaClass(aClass);
    if (javaClass.isEmpty()) {
        return empty();
    }

    Map<String, List<JavaMethod>> sourceMethodsByName = getMethods(javaClass.get()).toMap(sourceMethodName());
    Map<String, List<Method>> reflectionMethodsByName = methods.toMap(reflectionMethodName());

    List<TestMethod> testMethods = new ArrayList<TestMethod>();
    TestMethodExtractor extractor = new TestMethodExtractor();
    for (String name : sourceMethodsByName.keySet()) {
        List<JavaMethod> javaMethods = sourceMethodsByName.get(name);
        List<Method> reflectionMethods = reflectionMethodsByName.get(name);
        testMethods.add(extractor.toTestMethod(aClass, javaMethods.get(0), reflectionMethods.get(0)));
        // TODO: If people overload test methods we will have to use the full name rather than the short name
    }

    Sequence<TestMethod> myTestMethods = sequence(testMethods);
    Sequence<TestMethod> parentTestMethods = collectTestMethods(aClass.getSuperclass(), methods);

    return myTestMethods.join(parentTestMethods);
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:24,代码来源:TestParser.java

示例8: generateFile

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
public void generateFile(final JavaClass javaClass, final String... templateNames) throws GeradorException {
	
	if (javaClass == null) {
		throw new IllegalArgumentException("Error javaClass==null! Informe uma classe de entidade para geracao de c�digo!",
				new NullPointerException("Error javaClass==null! Informe uma classe de entidade para geracao de c�digo!"));
	}
	if (templateNames == null) {
		throw new IllegalArgumentException("Error templateNames==null! Informe os nomes dos templates a serem processados!",
				new NullPointerException("Error templateNames==null!"));
	}
	
	for (final String templateName : templateNames) {
		final ITemplateRules templateRules = templateRulesFactory.getTemplateRules(templateName);
		this.generateFile(javaClass, templateRules);
	}
	
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:18,代码来源:AbstractGeradorController.java

示例9: getClassName

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Determina que será o classname do arquivo gerado. Se não for java, retorna o nome do arquivo sem extensão.
 * 
 * @param javaClass
 * @param templateRules
 * @return
 * @throws FileWriterFactoryException
 */
protected String getClassName(JavaClass javaClass, ITemplateRules templateRules) throws FileWriterFactoryException {
	String className;

	try {
		if (javaClass == null) {
			className = templateRules.getFileName();
		} else {
			className = templateRules.getFileName(javaClass);
		}
	} catch (GeradorException e) {
		throw new FileWriterFactoryException("Erro: Não foi possivel determinar o nome do arquivo", e);
	}

	// Corrige o nome retirando a extensão
	if (className != null)
		className = className.split("\\.")[0];

	return className;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:28,代码来源:AbstractGeradorController.java

示例10: getFileName

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Implementação de IWriterFactory.getFileName(). Recupera como será o nome do arquivo gerado
 * 
 * @throws GeradorException
 */
public String getFileName(final JavaClass javaClass) throws GeradorException {
	
	final String domainName = this.getDomainName(javaClass);
	
	final String regexDestReplacement = this.getProperties().get(FreemarkerTemplateRules.PROP_REGEX_FILE_DEST_REPLACEMENT);
	if (StringUtils.isEmpty(regexDestReplacement)) {
		// filewriter.destfileNotSpecified=Nao é possivel determinar o fileName para {0}/{1} por que a propriedade {2} nao foi especificada!
		throw new FileWriterFactoryException(FreemarkerTemplateRules.mf.format("filewriter.destfileNotSpecified", this.getName(), javaClass
				.getName(), FreemarkerTemplateRules.PROP_REGEX_FILE_DEST_REPLACEMENT));
	}
	
	final String fileName = domainName.replaceAll(FreemarkerTemplateRules.REGEX_FULL_STRING, regexDestReplacement);
	
	return fileName;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:21,代码来源:FreemarkerTemplateRules.java

示例11: createWriter

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Objetivo final desta fábrica: Implementação de IWriterFactory.createWriter. Cria FileWriter que será o writer utilizado pelo engine do
 * gerador
 * 
 * @param templateRules
 *          contém as regras específicas do template que será processado
 * @param javaClass
 *          meta modelo da classe que servirá de insumo para processamento do template
 * @param temporario
 *          determina se o writer gerado deverá apontar para um destino definitivo ou temporário, caso o arquivo de destino já exista
 * @throws GeradorException
 */
@Override
protected Writer createWriter(final ITemplateRules templateRules, final JavaClass javaClass, final boolean temporario)
		throws GeradorException {
	
	// recupera o destDir
	final File destDir = this.getDestDir(templateRules, javaClass, temporario);
	// lanca exceção se não obtiver sucesso
	createDestDir(destDir);
	
	// recupera o destfile já criado
	final File destFile = this.getDestFile(templateRules, javaClass, destDir);
	// lanca excecao se não obtiver sucesso
	createDestFile(destFile);
	
	// cria FileWriter
	final Writer fileWriter = createFileWriter(destFile, templateRules);
	
	return fileWriter;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:32,代码来源:FileWriterFactory.java

示例12: getClassName

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Determina que será o classname do arquivo gerado. Se não for java, retorna o nome do arquivo sem extensão.
 * 
 * @param javaClass
 * @param templateRules
 * @return
 * @throws FileWriterFactoryException
 */
protected String getClassName(final JavaClass javaClass, final ITemplateRules templateRules) throws FileWriterFactoryException {
	String className;
	
	try {
		if (javaClass == null) {
			className = templateRules.getFileName();
		} else {
			className = templateRules.getFileName(javaClass);
		}
	} catch (final GeradorException e) {
		throw new FileWriterFactoryException("Erro: Não foi possivel determinar o nome do arquivo", e);
	}
	
	// Corrige o nome retirando a extensão
	if (className != null) {
		className = className.split("\\.")[0];
	}
	
	return className;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:29,代码来源:AbstractGeradorController.java

示例13: getDestDir

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Recupera diretório de destino para o código que será gerado. Não cria diretório no disco
 * 
 * @param templateRules
 * @param javaClass
 * @param temporario
 * @return
 * @throws GeradorException
 */
protected File getDestDir(final ITemplateRules templateRules, final JavaClass javaClass, final boolean temporario)
		throws GeradorException {
	// Caminho do diretório base
	final File baseDir = getBaseDir();
	
	// Coloca um sufixo no final de baseDir, caso tenha sido especificado. Exemplo src/main/java; src/main/webapp, onde "java" e "webapp"
	// são sufixos.
	final File baseDirSufix = getBaseDirSufix(baseDir, templateRules, temporario);
	
	// compoe caminho completo do diretório do arquivo
	final String dirRelativePath = getDirRelativePath(templateRules, javaClass);
	final File baseGenDir = new File(baseDirSufix, dirRelativePath);
	
	return baseGenDir;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:25,代码来源:FileWriterFactory.java

示例14: isGenerateRegex

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
/**
 * Verifica se as propriedades especificadas no map regexRules batem com as propriedades da JavaClass informada.
 * 
 * @param javaClass
 * @return
 */
protected boolean isGenerateRegex(final JavaClass javaClass) {
	final Set<String> keys = this.regexRules.keySet();
	// itera todas as chaves
	for (final String keyProp : keys) {
		
		String jcPropValue;
		try {
			jcPropValue = BeanUtilsBean.getInstance().getProperty(javaClass, keyProp);
		} catch (final Exception e) {
			// se a propriedade n�o existe sai do for
			break;
		}
		
		final String regexRule = this.regexRules.get(keyProp);
		
		// se o valor encontrado � diferente do valor esperado n�o roda do template
		if (jcPropValue != null && !jcPropValue.matches(regexRule)) {
			this.log.warn(FreemarkerTemplateRules.mf.format("rules.regexmap", this.template.getName(), javaClass.getName(), keyProp,
					jcPropValue, regexRule));
			return false;
		}
	}
	
	return true;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:32,代码来源:FreemarkerTemplateRules.java

示例15: of

import com.thoughtworks.qdox.model.JavaClass; //导入依赖的package包/类
public static JavaField of(com.thoughtworks.qdox.model.JavaField javaField, List<JavaClass> domainClasses,
                           MappingRespository mappingRespository) {
    JavaField field = new JavaField();
    field.model = javaField;
    field.mapping = mappingRespository.getMapping(javaField);
    field.partOfDomain = domainClasses.stream().anyMatch(javaField.getType()::equals);
    return field;
}
 
开发者ID:jboz,项目名称:living-documentation,代码行数:9,代码来源:JavaField.java


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