You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by si...@apache.org on 2013/05/13 11:31:08 UTC
svn commit: r1481749 -
/oltu/whiteboard/simonetripodi/oltu-commons/src/main/stylesheet/commons.xsl
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() > 1">, </xsl:if><xsl:value-of select="@field" />
</xsl:template>