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

Commit a704184

Browse files
author
Gerald Boersma
committed
#9 Properly display types / return types / parameter types for attributes, methods and constructors- i.e. when using generics / type variables.
1 parent 3fa399d commit a704184

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/main/java/info/leadinglight/umljavadoclet/model/ModelClass.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,11 @@ private void mapParamDependencies(ModelClass modelClass) {
456456
private void mapFields() {
457457
List<Field> fields = new ArrayList<>();
458458
for (FieldDoc fieldDoc: _classDoc.fields(false)) {
459-
Field mappedField = new Field(fieldDoc.name(), shortName(fieldDoc.type()), mapVisibility(fieldDoc), fieldDoc.isStatic());
459+
Type type = fieldDoc.type();
460+
String typeName = type.asTypeVariable() != null
461+
? type.asTypeVariable().simpleTypeName()
462+
: shortName(type);
463+
Field mappedField = new Field(fieldDoc.name(), typeName, mapVisibility(fieldDoc), fieldDoc.isStatic());
460464
fields.add(mappedField);
461465
}
462466
orderVisibility(fields, _fields);
@@ -467,7 +471,11 @@ private void mapConstructors() {
467471
for (ConstructorDoc consDoc: _classDoc.constructors(false)) {
468472
List<MethodParameter> params = new ArrayList<>();
469473
for (Parameter param: consDoc.parameters()) {
470-
params.add(new MethodParameter(shortName(param.type()), param.name()));
474+
Type paramType = param.type();
475+
String paramTypeName = paramType.asTypeVariable() != null
476+
? paramType.asTypeVariable().simpleTypeName()
477+
: shortName(param.type());
478+
params.add(new MethodParameter(paramTypeName, param.name()));
471479
}
472480
Constructor constructor = new Constructor(consDoc.name(), params, mapVisibility(consDoc));
473481
constructors.add(constructor);
@@ -480,11 +488,19 @@ private void mapMethods() {
480488
for (MethodDoc methodDoc: _classDoc.methods(false)) {
481489
List<MethodParameter> params = new ArrayList<>();
482490
for (Parameter param: methodDoc.parameters()) {
483-
params.add(new MethodParameter(shortName(param.type()), param.name()));
491+
Type paramType = param.type();
492+
String paramTypeName = paramType.asTypeVariable() != null
493+
? paramType.asTypeVariable().simpleTypeName()
494+
: shortName(param.type());
495+
params.add(new MethodParameter(paramTypeName, param.name()));
484496
}
497+
Type returnType = methodDoc.returnType();
498+
String returnTypeName = returnType.asTypeVariable() != null
499+
? returnType.asTypeVariable().simpleTypeName()
500+
: shortName(returnType);
485501
Method method = new Method(methodDoc.name(),
486502
params,
487-
shortName(methodDoc.returnType()),
503+
returnTypeName,
488504
mapVisibility(methodDoc),
489505
methodDoc.isAbstract(),
490506
methodDoc.isStatic());

0 commit comments

Comments
 (0)