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


Java JavaField类代码示例

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


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

示例1: arrayRequiredAppearsInFieldJavadoc

import com.thoughtworks.qdox.model.JavaField; //导入依赖的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.JavaField; //导入依赖的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: visit

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
@Override
public Object visit(FieldRef fieldRef) {
	try {
		return super.visit(fieldRef);
	} catch (IllegalArgumentException iae) {
		// let's try again! (some refs are not found unfortunately ...)
		JavaPackage currentPackage = context.getPackage();
		JavaClass targetClass = null;
		for (JavaClass c : currentPackage.getClasses()) {
			if (c.getName().equals(fieldRef.getNamePart(0))) {
				targetClass = c;
			}
		}

		if (targetClass == null) throw iae;

		JavaField field = targetClass.getFieldByName(fieldRef.getNamePart(1));
		return getFieldReferenceValue(field);
	}
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:21,代码来源:SimpleEvaluatingVisitor.java

示例4: testCollectAllFields

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
@Test
public void testCollectAllFields() {

    /*
        situation, where we want have a class with no fields, extending
        another parent class that has field "number".

        Verify, that "recursivelyCollectAllFields()" method detects
        that child class has "number" field.
     */
    when( mockedField.getName() ).thenReturn("number");
    when( jc.getSuperJavaClass().getFields()).thenReturn( ImmutableList.of(mockedField) );
    when( jc.getFields() ).thenReturn(Lists.newArrayList());

    // collect all the fields (including parent ones)
    final List<JavaField> javaFields = BuildHelper.collectParentFields(jc);

    assertNotNull(javaFields);
    assertTrue(javaFields.stream().anyMatch((field) -> field.getName().equals("number")));
    assertTrue(javaFields.stream().noneMatch((field) -> field.getName().equals("nonExistingField")));
}
 
开发者ID:p-i,项目名称:soap-to-jpa,代码行数:22,代码来源:BuildHelperTest.java

示例5: processField

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
private void processField(List<String> lines, JavaClass javaClass, JavaField field) {
    field.getAnnotations().forEach(ja -> {
        if (ja.getType().getName().equals(PROPERTY)) {
            lines.add(expand(javaClass, ja.getNamedParameter("name").toString()) +
                              SEP + type(field) +
                              SEP + defaultValue(javaClass, field, ja) +
                              SEP + description(ja));
        }
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:OnosCfgMojo.java

示例6: defaultValue

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
private String defaultValue(JavaClass javaClass, JavaField field,
                            JavaAnnotation annotation) {
    String ft = field.getType().getName().toLowerCase();
    String defValueName = ft.equals("boolean") ? "boolValue" :
            ft.equals("string") ? "value" : ft + "Value";
    Object dv = annotation.getNamedParameter(defValueName);
    return dv == null ? "" : expand(javaClass, dv.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:OnosCfgMojo.java

示例7: getFieldReferenceValue

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
@Override
public Object getFieldReferenceValue(JavaField field) {
	String expression = field.getInitializationExpression();
	if (expression.startsWith("\"")) expression = expression.substring(1);
	if (expression.endsWith("\"")) expression = expression.substring(0, expression.length() - 1);
	return expression;
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:8,代码来源:SimpleEvaluatingVisitor.java

示例8: testExtractImplementations

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

    // given: a class that has one field marked with @XmlElements annotation
    final JavaProjectBuilder builder = new JavaProjectBuilder();
    builder.addSourceTree(new File(baseTestDir));

    final DefaultJavaClass jc = (DefaultJavaClass) builder.getClassByName("net.pibenchmark.testFiles.SimpleClassWithPolymorphicField");
    assertNotNull(jc);

    final JavaField lstTestField = jc.getFieldByName("lstTest");
    assertNotNull(lstTestField);

    // when: we request its implementations
    final Set<String> setImplementations = BuildHelper.extractImplementations(lstTestField);

    // then: it returns all the classes declared within @XmlElements annotation
    assertFalse(setImplementations.isEmpty());

    // and: it contains two classes
    System.out.println("---" + setImplementations);
    assertTrue(setImplementations.contains("SimpleClassOne"));
    assertTrue(setImplementations.contains("SimpleClassTwo"));

    // and: it does not contain the first class, that doesn't have an argument "type"
    assertFalse(setImplementations.contains("Object"));
}
 
开发者ID:p-i,项目名称:soap-to-jpa,代码行数:28,代码来源:BuildHelperTest.java

示例9: generateEnumBuilderFor

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
private PojoEnum generateEnumBuilderFor(JavaClass javaClass, STGroup template) throws IOException {
	PojoEnum enumPojo = new PojoEnum(getGeneratedClassPackage(javaClass), getPojoClassName(javaClass.getName()), javaClass.getFullyQualifiedName());

	for (JavaField field : javaClass.getFields()) {
		if (!field.getName().equals("value")) {
			enumPojo.addType(field.getName());
		}
	}

	return enumPojo;
}
 
开发者ID:sergypv,项目名称:thrift-pojo-generator-maven-plugin,代码行数:12,代码来源:ThriftPojoGenerator.java

示例10: originalPropertyNamesAppearInJavaDoc

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

    schemaRule.generateAndCompile("/schema/javaName/javaName.json", "com.example.javaname");
    File generatedJavaFile = schemaRule.generated("com/example/javaname/JavaName.java");

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

    JavaClass classWithDescription = javaDocBuilder.getClassByName("com.example.javaname.JavaName");

    JavaField javaPropertyField = classWithDescription.getFieldByName("javaProperty");
    assertThat(javaPropertyField.getComment(), containsString("Corresponds to the \"propertyWithJavaName\" property."));

    JavaField javaEnumField = classWithDescription.getFieldByName("javaEnum");
    assertThat(javaEnumField.getComment(), containsString("Corresponds to the \"enumWithJavaName\" property."));

    JavaField javaObjectField = classWithDescription.getFieldByName("javaObject");
    assertThat(javaObjectField.getComment(), containsString("Corresponds to the \"objectWithJavaName\" property."));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:JavaNameIT.java

示例11: type

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
private String type(JavaField field) {
    String ft = field.getType().getName().toUpperCase();
    return ft.equals("INT") ? "INTEGER" : ft;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:OnosCfgMojo.java

示例12: expand

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
private String expand(JavaClass javaClass, String value) {
    JavaField field = javaClass.getFieldByName(value);
    return field == null ? stripQuotes(value) :
            stripQuotes(field.getCodeBlock().replaceFirst(".*=", "").replaceFirst(";$", ""));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:OnosCfgMojo.java

示例13: generateKeyTableFromSources

import com.thoughtworks.qdox.model.JavaField; //导入依赖的package包/类
/**
 * Example for getting comments from a java file using qdox.
 * This requires access to the actual java file in the list of ressources.
 * (Use source folder as output folder for class files in eclipse)
 */
private void generateKeyTableFromSources(){
	// read java sources to parser from qdox
	InputStream stream = RegKeys.class.getResourceAsStream("RegKeys.java");
	InputStreamReader reader = new InputStreamReader(stream);
	JavaDocBuilder builder = new JavaDocBuilder();
	builder.addSource(reader);
	
	// generate table with line wrapping cells in colum 2
	final int wordWrapColumnIndex = 1;
	descTable = new JTable() {    
		/**
		 * 
		 */
		private static final long serialVersionUID = 7516482246121817003L;

		public TableCellRenderer getCellRenderer(int row, int column) {
			if (column == wordWrapColumnIndex ) {
				return new MultilineTableCell();
			}
			else {
				return super.getCellRenderer(row, column);
			}
		}
	};
	
	// Use qdox parser to parse RegKeys sources
	JavaClass cls = builder.getClassByName("edu.stanford.rsl.conrad.utils.RegKeys");
	// get list of fields
	JavaField[] fields = cls.getFields();

	// build table model
	String [][] tableData = new String [fields.length][2];
	String [] label = {"Key", "Description"};
	int i = 0;
	for (JavaField field : fields){
		tableData[i][0] = field.getName();
		tableData[i][1] = field.getComment();
		if (tableData[i][1] != null){
			tableData[i][1] = field.getComment().replace("<BR>", "\n")	
			.replace("<br>", "\n")
			.replace("<b>", "\n")
			.replace("</b>", "\n");
		} else {
			tableData[i][1] = "";
		}
		i++;
	}

	DefaultTableModel model = new DefaultTableModel(tableData, label);
	descTable.setModel(model);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:57,代码来源:RegistryEditor.java

示例14: requiredAppearsInFieldJavadoc

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

    JavaField javaField = classWithRequired.getFieldByName("requiredProperty");
    String javaDocComment = javaField.getComment();

    assertThat(javaDocComment, containsString("(Required)"));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:RequiredIT.java

示例15: nonRequiredFiedHasNoRequiredText

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

    JavaField javaField = classWithRequired.getFieldByName("nonRequiredProperty");
    String javaDocComment = javaField.getComment();

    assertThat(javaDocComment, not(containsString("(Required)")));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:RequiredIT.java


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