Permalink
Browse files

adds toString on generated ParameterizedType

It eases the debugging when parameterized types are created using
the Types.newParameterizedType factory method.
  • Loading branch information...
a-peyrard committed Apr 30, 2015
1 parent 51982bb commit dee37c826dca531b3e87fd9a4281af86aa1366db
Showing with 40 additions and 0 deletions.
  1. +40 −0 restx-common/src/main/java/restx/common/Types.java
@@ -57,6 +57,46 @@ public boolean equals(Object obj) {
}
return false;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Type ownerType = getOwnerType();
if (ownerType != null) {
if (ownerType instanceof Class) {
sb.append(((Class) ownerType).getName());
} else {
sb.append(ownerType.toString());
}
sb.append(".");
if (ownerType instanceof ParameterizedType) {
sb.append(rawType.getName().replace(((Class) ((ParameterizedType) ownerType).getRawType()).getName() + "$", ""));
} else {
sb.append(rawType.getName());
}
} else {
sb.append(rawType.getName());
}
if (arguments != null && arguments.length > 0) {
sb.append("<");
boolean first = true;
for (Type current : arguments) {
if (!first) {
sb.append(", ");
}
sb.append(current.toString()); // getTypeName() in jse8
first = false;
}
sb.append(">");
}
return sb.toString();
}
};
}

0 comments on commit dee37c8

Please sign in to comment.