You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2007/05/21 21:43:17 UTC
svn commit: r540255 -
/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java
Author: cschoett
Date: Mon May 21 12:43:17 2007
New Revision: 540255
URL: http://svn.apache.org/viewvc?view=rev&rev=540255
Log:
Updated AptType's getFormalTypeParameters() method to be a bit more explicit about specifing the bounds contained within a TypeParameterDeclaration. I have seen some APT implementations which do not include the bounds when a toString() is performed on an TypeParameterDeclaration.
No new tests added, we already have good coverage of generics in ControlInterfaces in the control's DRTs.
Drts: Beehive Controls
Modified:
beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java
Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java?view=diff&rev=540255&r1=540254&r2=540255
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptType.java Mon May 21 12:43:17 2007
@@ -24,6 +24,7 @@
import com.sun.mirror.declaration.TypeParameterDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.Modifier;
+import com.sun.mirror.type.ReferenceType;
/**
* The AptType abstract class defines a base set of methods that are generally available
@@ -85,7 +86,7 @@
{
if ( _typeDecl == null )
return "";
-
+
return _typeDecl.getSimpleName();
}
@@ -96,7 +97,7 @@
{
Collection<TypeParameterDeclaration> ftColl = _typeDecl.getFormalTypeParameters();
if (ftColl.size() == 0)
- return "";
+ return "";
StringBuffer sb = new StringBuffer("<");
boolean isFirst = true;
@@ -106,13 +107,45 @@
sb.append(",");
else
isFirst = false;
-
- if (namesOnly)
+
+ if (namesOnly) {
sb.append(tpDecl.getSimpleName());
- else
- sb.append(tpDecl.toString());
+ }
+ else {
+ sb.append(tpDecl.getSimpleName());
+ String bounds = getBoundsStr(tpDecl);
+ if (bounds != null && bounds.length() > 0) {
+ sb.append(' ');
+ sb.append(bounds);
+ }
+ }
}
sb.append(">");
+ return sb.toString();
+ }
+
+ /**
+ * Helper method to build a string of bounds for a TypeParameterDeclaration.
+ */
+ private String getBoundsStr(TypeParameterDeclaration tpDecl) {
+ Collection<ReferenceType> bounds = tpDecl.getBounds();
+ StringBuilder sb = new StringBuilder();
+ boolean isFirst = true;
+
+ for (ReferenceType rt : bounds) {
+ if ("java.lang.Object".equals(rt.toString())) {
+ continue;
+ }
+
+ if (!isFirst) {
+ sb.append(",");
+ }
+ else {
+ sb.append("extends ");
+ isFirst = false;
+ }
+ sb.append(rt.toString());
+ }
return sb.toString();
}