oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1481749 - /oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl
Date Mon, 13 May 2013 09:31:08 GMT
Author: simonetripodi
Date: Mon May 13 09:31:07 2013
New Revision: 1481749

URL: http://svn.apache.org/r1481749
Log:
handled mandatory parameters when Builder#build() is invoked

Modified:
    oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl

Modified: oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl
URL: http://svn.apache.org/viewvc/oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl?rev=1481749&r1=1481748&r2=1481749&view=diff
==============================================================================
--- oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl (original)
+++ oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl Mon May 13
09:31:07 2013
@@ -109,7 +109,8 @@ public final class <xsl:value-of select=
          */
         public <xsl:value-of select="@name" /> build()
         {
-            return new <xsl:value-of select="@name" />(<xsl:apply-templates select="parameter"
mode="builderArg" />, auxParameters);
+            <xsl:apply-templates select="parameter" mode="checkMandatory" />
+            return new <xsl:value-of select="@name" />( <xsl:apply-templates select="parameter"
mode="builderArg" />, auxParameters );
         }
 
     }
@@ -231,6 +232,14 @@ public final class <xsl:value-of select=
         }
 </xsl:template>
 
+  <xsl:template match="parameter" mode="checkMandatory">
+    <xsl:if test="@required = 'true'">if ( <xsl:value-of select="@field" /> ==
null )
+            {
+                throw new IllegalStateException( "Parameter '<xsl:value-of select="@field"
/>' [<xsl:value-of select="@name" />] is mandatory." );
+            }
+            </xsl:if>
+  </xsl:template>
+
   <xsl:template match="parameter" mode="builderArg">
     <xsl:if test="position() &gt; 1">, </xsl:if><xsl:value-of select="@field"
/>
   </xsl:template>



Mime
View raw message