<!DOCTYPE html>
<html><head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../logi/reset.css" />
	<link rel="stylesheet" type="text/css" href="features.css" />
	<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
	<meta name="description" content="Spice up your java" />
	<title>@ToString</title>
</head><body><div id="pepper">
	<div class="minimumHeight"></div>
	<div class="meat">
		<div class="header"><a href="../index.html">Project Lombok</a></div>
		<h1>@ToString</h1>
		<div class="byline">No need to start a debugger to see your fields: Just let lombok generate a <code>toString</code> for you!</div>
		<div class="overview">
			<h3>Overview</h3>
			<p>
			Any class definition may be annotated with <code>@ToString</code> to let lombok generate an implementation of the
			<code>toString()</code> method. By default, it'll print your class name, along with each field, in order, separated by commas.
			</p><p>
			By setting the <code>includeFieldNames</code> parameter to <em>true</em> you can add some clarity (but also quite some length) to
			the output of the <code>toString()</code> method.
			</p><p>
			By default, all non-static fields will be printed. If you want to skip some fields, you can name them in the <code>exclude</code> parameter; each named
			field will not be printed at all. Alternatively, you can specify exactly which fields you wish to be used by naming them in the <code>of</code> parameter.
			</p><p>
			By setting <code>callSuper</code> to <em>true</em>, you can include the output of the superclass implementation of <code>toString</code> to the
			output. Be aware that the default implementation of <code>toString()</code> in <code>java.lang.Object</code> is pretty much meaningless, so you
			probably don't want to do this unless you are extending another class.
			</p>
		</div>
		<div class="snippets">
			<div class="pre">
				<h3>With Lombok</h3>
				<div class="snippet">@HTML_PRE@</div>
			</div>
			<div class="sep"></div>
			<div class="post">
				<h3>Vanilla Java</h3>
				<div class="snippet">@HTML_POST@</div>
			</div>
		</div>
		<div style="clear: left;"></div>
		<div class="overview">
			<h3>Small print</h3><div class="smallprint">
				<p>
				If there is <em>any</em> method named <code>toString</code> regardless of parameters or return type, no method will be generated, and instead
				a warning is emitted explaining that your <code>@ToString</code> annotation is doing nothing.
				</p><p>
				Arrays are printed via <code>Arrays.deepToString</code>, which means that arrays that contain themselves will result in <code>StackOverflowError</code>s. However,
				this behaviour is no different from e.g. <code>ArrayList</code>.
				</p><p>
				Attempting to exclude fields that don't exist or would have been excluded anyway (because they are static) results in warnings on the named fields.
				You therefore don't have to worry about typos.
				</p><p>
				Having both <code>exclude</code> and <code>of</code> generates a warning; the <code>exclude</code> parameter will be ignored in that case.
				</p><p>
				We don't promise to keep the output of the generated <code>toString()</code> methods the same between lombok versions. You should never design your API so that
				other code is forced to parse your <code>toString()</code> output anyway!
				</p><p>
				By default, any variables that start with a $ symbol are excluded automatically. You can only include them by using the 'of' parameter.
				</p><p>
				If a getter exists for a field to be included, it is called instead of using a direct field reference. This behaviour can be suppressed:<br />
				<code>@ToString(doNotUseGetters = true)</code>
				</p><p>
					<code>@ToString</code> can also be used on an enum definition.
				</p>
			</div>
		</div>
		<div class="footer">
			<a href="index.html">Back to features</a> | <a href="GetterLazy.html">Previous feature (@Getter(lazy=true))</a> | <a href="EqualsAndHashCode.html">Next feature (@EqualsAndHashCode)</a><br />
			<a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2009-2011 The Project Lombok Authors, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span>
		</div>
		<div style="clear: both;"></div>
	</div>
</div>
<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
	try {
		var pageTracker = _gat._getTracker("UA-9884254-1");
		pageTracker._trackPageview();
	} catch(err) {}
</script>
</body></html>