Source

xwork / docs / wikidocs / Key Annotation.html

<html>
    <head>
        <title>XWork - 
         Annotation
        </title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <p><p/>Sets the Key for type conversion.</p>

<h2><a name="KeyAnnotation-Usage"></a>Usage</h2>

<p><p/>The Key annotation must be applied at field or method level.</p>

<h2><a name="KeyAnnotation-Parameters"></a>Parameters</h2>

<p><table>
<thead>
<tr>
<th>Parameter</th>
<th>Required</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
<td>no</td>
<td>java.lang.Object.class</td>
<td>The key property value.</td>
</tr>
</tbody>
</table></p>

<h2><a name="KeyAnnotation-Examples"></a>Examples</h2>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// The key property <span class="code-keyword">for</span> User objects within the users collection is the &lt;code&gt;userName&lt;/code&gt; attribute.
</span>@Key( value = java.lang.<span class="code-object">Long</span>.class )
<span class="code-keyword">private</span> Map&lt;<span class="code-object">Long</span>, User&gt; userMap;</pre>
</div></div>

                    			    </td>
		    </tr>
	    </table>
    </body>
</html>