本文整理汇总了Java中beast.core.Description类的典型用法代码示例。如果您正苦于以下问题:Java Description类的具体用法?Java Description怎么用?Java Description使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Description类属于beast.core包,在下文中一共展示了Description类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDescriptions
import beast.core.Description; //导入依赖的package包/类
/**
* Check all plug-ins have a proper description so that
* everything is at least moderately well documented. *
*/
@Test
public void testDescriptions() {
final List<String> pluginNames = AddOnManager.find(beast.core.BEASTObject.class, AddOnManager.IMPLEMENTATION_DIR);
final List<String> undocumentedPlugins = new ArrayList<String>();
for (final String beastObjectName : pluginNames) {
try {
final Class<?> pluginClass = Class.forName(beastObjectName);
final Annotation[] classAnnotations = pluginClass.getAnnotations();
boolean hasSatisfactoryDescription = false;
for (final Annotation annotation : classAnnotations) {
if (annotation instanceof Description) {
final Description description = (Description) annotation;
final String descriptionString = description.value();
if (isProperDocString(descriptionString)) {
hasSatisfactoryDescription = true;
}
}
}
if (!hasSatisfactoryDescription) {
undocumentedPlugins.add(beastObjectName);
}
} catch (Exception e) {
}
}
assertTrue("No proper description for: " + undocumentedPlugins.toString(), undocumentedPlugins.size() == 0);
}
示例2: getInheritableDescription
import beast.core.Description; //导入依赖的package包/类
/**
* Extract description from @Description annotation
* but only if the description is inheritable *
*/
String getInheritableDescription(Class<?> beastObjectClass) {
String str = "";
Class<?> superClass = beastObjectClass.getSuperclass();
if (superClass != null) {
String superName = getInheritableDescription(superClass);
if (superName != null) {
str += superName + "<br/>";
}
}
Annotation[] classAnnotations = beastObjectClass.getAnnotations();
for (Annotation annotation : classAnnotations) {
if (annotation instanceof Description) {
Description description = (Description) annotation;
if (description.isInheritable()) {
str += description.value();
} else {
return null;
}
}
}
return str;
}