本文整理汇总了Java中com.sun.javadoc.TypeVariable.bounds方法的典型用法代码示例。如果您正苦于以下问题:Java TypeVariable.bounds方法的具体用法?Java TypeVariable.bounds怎么用?Java TypeVariable.bounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.javadoc.TypeVariable
的用法示例。
在下文中一共展示了TypeVariable.bounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parameterLink
import com.sun.javadoc.TypeVariable; //导入方法依赖的package包/类
/**
* Appends to the current document the given type parameter
* as a valid markdown link.
*
* @param source Source package to start URL from.
* @param type Target type parameter to reach from this package.
*/
private void parameterLink(final PackageDoc source, final Type type) {
final WildcardType wildcard = type.asWildcardType();
if (wildcard != null) {
character('?');
}
else {
final TypeVariable variableType = type.asTypeVariable();
if (variableType != null) {
final Type [] bounds = variableType.bounds();
if (bounds.length > 0) {
text("? extends ");
for (int i = 0; i < bounds.length; i++) {
typeLink(source, bounds[i]);
if (i < bounds.length - 1) {
text(" & ");
}
}
}
}
else {
typeLink(source, type);
}
}
}
示例2: parseGeneric
import com.sun.javadoc.TypeVariable; //导入方法依赖的package包/类
/**
* Parse type variables for generics
*
* @param typeVariable
* @return
*/
protected Generic parseGeneric(TypeVariable typeVariable) {
Generic genericNode = objectFactory.createGeneric();
genericNode.setName(typeVariable.typeName());
genericNode.setIdentifier(parseIdentifier((Type) typeVariable));
genericNode.setId(typeVariable.simpleTypeName());
for (Type bound : typeVariable.bounds()) {
genericNode.getBound().add(parseTypeInfo(bound));
}
return genericNode;
}
示例3: start
import com.sun.javadoc.TypeVariable; //导入方法依赖的package包/类
public static boolean start(RootDoc root) throws IOException {
Map<String, List<String>> packageMap = new TreeMap<>();
for (ClassDoc classDoc : root.classes()) {
String fromPackage = classDoc.containingPackage().name();
List<String> packageRefs = packageMap.get(fromPackage);
if (packageRefs == null) {
packageRefs = new LinkedList<String>();
packageMap.put(fromPackage, packageRefs);
}
Set<ClassDoc> relatedClasses = new TreeSet<>();
addIfPresent(relatedClasses, classDoc.superclass());
addIfPresent(relatedClasses, classDoc.containingClass());
addIfPresent(relatedClasses, classDoc.interfaces());
//TODO: This may not do what I think it does
for (TypeVariable typeVariable : classDoc.typeParameters()) {
for (Type bound : typeVariable.bounds()) {
System.out.print("Found bound parameter: " + bound.toString());
addIfPresent(relatedClasses, bound.asClassDoc());
}
}
// boolean relationsFound = false;
for (ClassDoc relatedClass : relatedClasses) {
String toPackage = relatedClass.containingPackage().name();
if (toPackage.startsWith("org.apache") && !toPackage.equals(fromPackage)) {
packageRefs.add(toPackage);
// WRITER.write(String.format("\"%s\" -> \"%s\";\n", fromName, toName));
// relationsFound = true;
}
};
// if (!relationsFound) {
// WRITER.write(String.format("\"%s\";\n", fromName)); //single node
// }
}
//write out package links
for (String fromPackageName : packageMap.keySet()) {
List<String> toPackageList = packageMap.get(fromPackageName);
if (toPackageList.isEmpty()) {
WRITER.write(String.format("\"%s\";\n", fromPackageName)); //single node
continue;
}
//get the packages and number of times they occur
Map<String, Long> toPackageCounts = toPackageList.stream()
.collect(
Collectors.groupingBy(p -> p,
Collectors.counting())
);
for (String toPackageName : toPackageCounts.keySet()) {
WRITER.write(String.format("\"%s\" -> \"%s\" [weight=\"%d\"]\n",
fromPackageName, toPackageName,
toPackageCounts.get(toPackageName)));
}
}
return true;
}
示例4: renderOn
import com.sun.javadoc.TypeVariable; //导入方法依赖的package包/类
@Override
public void renderOn(HtmlCanvas html) throws IOException {
if (type.isPrimitive()) {
html.write(type.typeName() + type.dimension());
} else {
String name;
ClassDoc classDoc = type.asClassDoc();
DocReferenceable referenceable = generator.getRefLocator().getClassDocRef(classDoc);
String ref = PageRenderer.getPage(html).getReferenceTo(referenceable);
if ((flags & FQN) != 0) {
name = classDoc.qualifiedName();
} else {
name = referenceable.getName();
}
if ((flags & LINK) != 0 && ref != null) {
html.a(href(PageRenderer.getPage(html).getReferenceTo(referenceable))).content(name,
HtmlCanvas.NO_ESCAPE);
} else {
html.write(name);
}
}
ParameterizedType parameterizedType = type.asParameterizedType();
if (parameterizedType != null) {
Type[] typeArguments = parameterizedType.typeArguments();
if (typeArguments.length > 0) {
html.write("<");
for (int typeVarCount = 0; typeVarCount < typeArguments.length; typeVarCount++) {
Type typeArgument = typeArguments[typeVarCount];
if (typeVarCount > 0) {
html.write(", ");
}
renderReferenceable(generator.getRefLocator().getClassDocRef(typeArgument.asClassDoc()), html);
}
html.write(">");
}
} else if (!type.isPrimitive()) {
TypeVariable[] typeVariables = type.asClassDoc().typeParameters();
if (typeVariables.length > 0) {
html.write("<");
for (int typeVarCount = 0; typeVarCount < typeVariables.length; typeVarCount++) {
TypeVariable typeVariable = typeVariables[typeVarCount];
if (typeVarCount > 0) {
html.write(", ");
}
html.write(typeVariable.typeName());
if ((flags & BOUNDS) != 0) {
Type[] bounds = typeVariable.bounds();
if (bounds.length > 0) {
html.write(" extends ");
for (int boundCnt = 0; boundCnt < bounds.length; boundCnt++) {
ClassDoc boundClass = bounds[boundCnt].asClassDoc();
if (boundCnt > 0) {
html.write(" & ");
}
renderReferenceable(generator.getRefLocator().getClassDocRef(boundClass), html);
}
}
}
}
html.write(">");
}
}
}
示例5: toTypeParametersNode
import com.sun.javadoc.TypeVariable; //导入方法依赖的package包/类
/**
* Generates a child node for each generic type parameter.
* @param doc [description]
* @return [description]
*/
private static XMLNode toTypeParametersNode(ClassDoc doc) {
TypeVariable[] typeParameters = doc.typeParameters();
ParamTag[] typeParameterTags = doc.typeParamTags();
XMLNode node = null;
if (typeParameters != null && typeParameters.length > 0) {
node = new XMLNode("typeParameters");
for (TypeVariable i : typeParameters) {
XMLNode paramNode = new XMLNode("parameter");
paramNode.attribute("name", i.typeName());
Type[] bounds = i.bounds();
if (bounds != null && bounds.length > 0) {
XMLNode boundsNode = new XMLNode("bounds");
for (Type t : bounds) {
XMLNode typeNode = new XMLNode("type");
typeNode.attribute("fulltype", t.toString());
typeNode.attribute("type", t.typeName());
typeNode.attribute("name", t.qualifiedTypeName());
boundsNode.child(typeNode);
}
paramNode.child(boundsNode);
}
if (typeParameterTags != null && typeParameterTags.length > 0) {
ParamTag tag = null;
for (ParamTag j : typeParameterTags) {
// take the first one
if (j.isTypeParameter() && j.parameterName().equals(i.typeName())) {
tag = j;
break;
}
}
if (tag != null) {
XMLNode commentNode = new XMLNode("comment");
commentNode.text(toComment(tag));
paramNode.child(commentNode);
}
}
node.child(paramNode);
}
}
return node;
}