本文整理汇总了Java中com.thoughtworks.qdox.model.JavaClass.getFieldByName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClass.getFieldByName方法的具体用法?Java JavaClass.getFieldByName怎么用?Java JavaClass.getFieldByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.qdox.model.JavaClass
的用法示例。
在下文中一共展示了JavaClass.getFieldByName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)"));
}
示例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)"));
}
示例3: visit
import com.thoughtworks.qdox.model.JavaClass; //导入方法依赖的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);
}
}
示例4: originalPropertyNamesAppearInJavaDoc
import com.thoughtworks.qdox.model.JavaClass; //导入方法依赖的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."));
}
示例5: expand
import com.thoughtworks.qdox.model.JavaClass; //导入方法依赖的package包/类
private String expand(JavaClass javaClass, String value) {
JavaField field = javaClass.getFieldByName(value);
return field == null ? stripQuotes(value) :
stripQuotes(field.getCodeBlock().replaceFirst(".*=", "").replaceFirst(";$", ""));
}