Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
#9 Refactor to prepare for displaying bounds with type variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Boersma committed Apr 11, 2020
1 parent fa43400 commit 4b991f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/main/java/info/leadinglight/umljavadoclet/model/ModelClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,21 @@ private void mapParamDependencies(ModelClass modelClass) {
}
}
}

private String getTypeName(Type type) {
// TODO The simpleTypeName call on the type does not include any bounds for any embedded types.
// Need to build our own.
String typeName = type.asTypeVariable() != null
? type.asTypeVariable().simpleTypeName()
: shortName(type);
return typeName;
}

private void mapFields() {
List<Field> fields = new ArrayList<>();
for (FieldDoc fieldDoc: _classDoc.fields(false)) {
Type type = fieldDoc.type();
String typeName = type.asTypeVariable() != null
? type.asTypeVariable().simpleTypeName()
: shortName(type);
String typeName = getTypeName(type);
Field mappedField = new Field(fieldDoc.name(), typeName, mapVisibility(fieldDoc), fieldDoc.isStatic());
fields.add(mappedField);
}
Expand All @@ -478,9 +485,7 @@ private void mapConstructors() {
List<MethodParameter> params = new ArrayList<>();
for (Parameter param: consDoc.parameters()) {
Type paramType = param.type();
String paramTypeName = paramType.asTypeVariable() != null
? paramType.asTypeVariable().simpleTypeName()
: shortName(param.type());
String paramTypeName = getTypeName(paramType);
params.add(new MethodParameter(paramTypeName, param.name()));
}
Constructor constructor = new Constructor(consDoc.name(), params, mapVisibility(consDoc));
Expand All @@ -495,15 +500,11 @@ private void mapMethods() {
List<MethodParameter> params = new ArrayList<>();
for (Parameter param: methodDoc.parameters()) {
Type paramType = param.type();
String paramTypeName = paramType.asTypeVariable() != null
? paramType.asTypeVariable().simpleTypeName()
: shortName(param.type());
String paramTypeName = getTypeName(paramType);
params.add(new MethodParameter(paramTypeName, param.name()));
}
Type returnType = methodDoc.returnType();
String returnTypeName = returnType.asTypeVariable() != null
? returnType.asTypeVariable().simpleTypeName()
: shortName(returnType);
String returnTypeName = getTypeName(returnType);
Method method = new Method(methodDoc.name(),
params,
returnTypeName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
import java.util.ArrayList;
import java.util.HashMap;

// TODO Does not show the bounds for P on the diagram.
public class TestGenerics7<P extends ArrayList> extends HashMap<String,P> {
}

0 comments on commit 4b991f2

Please sign in to comment.