mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-27 20:25:27 +00:00
92 lines
4.2 KiB
HTML
92 lines
4.2 KiB
HTML
<!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>EXPERIMENTAL - @FieldDefaults</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>@FieldDefaults</h1>
|
|
<div class="byline">New default field modifiers for the 21st century.</div>
|
|
<div class="since">
|
|
<h3>Since</h3>
|
|
<p>
|
|
@FieldDefaults was introduced as experimental feature in lombok v0.11.4.
|
|
</p>
|
|
</div>
|
|
<div class="experimental">
|
|
<h3>Experimental</h3>
|
|
<p>
|
|
Experimental because:
|
|
<ul>
|
|
<li>New feature; unsure if this busts enough boilerplate</li>
|
|
<li>Would be nice if you could stick this on the package-info.java package to set the default for all classes in that package</li>
|
|
<li>Part of the work on @Value, which is experimental</li>
|
|
</ul>
|
|
Current status: <em>positive</em> - Currently we feel this feature may move out of experimental status with no or minor changes soon.
|
|
</div>
|
|
<div class="overview">
|
|
<h3>Overview</h3>
|
|
<p>
|
|
The <code>@FieldDefaults</code> annotation can add an access modifier (<code>public</code>, <code>private</code>, or <code>protected</code>)
|
|
to each field in the annotated class or enum. It can also add <code>final</code> to each field in the annotated class or enum.
|
|
</p>
|
|
</p><p>
|
|
To add <code>final</code> to each field, use <code>@FieldDefaults(makeFinal=true)</code>. Any non-final field which must remain nonfinal
|
|
can be annotated with <code>@NonFinal</code> (also in the <code>lombok.experimental</code> package).
|
|
</p><p>
|
|
To add an access modifier to each field, use <code>@FieldDefaults(level=AccessLevel.PRIVATE)</code>. Any field that does not already have an
|
|
access modifier (i.e. any field that looks like package private access) is changed to have the appropriate access modifier. Any package private
|
|
field which must remain package private can be annotated with <code>@PackagePrivate</code> (also in the <code>lombok.experimental</code> package).
|
|
</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 confKeys">
|
|
<h3>Supported configuration keys:</h3>
|
|
<dl>
|
|
<dt><code>lombok.fieldDefaults.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)</dt>
|
|
<dd>Lombok will flag any usage of <code>@FieldDefaults</code> as a warning or error if configured.</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="overview">
|
|
<h3>Small print</h3><div class="smallprint">
|
|
<p>
|
|
Like other lombok handlers that touch fields, any field whose name starts with a dollar (<code>$</code>) symbol is skipped entirely.
|
|
Such a field will not be modified at all.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="footer">
|
|
<a href="index.html">Back to experimental features</a> | <a href="ExtensionMethod.html">Previous feature (@ExtensionMethod)</a> | <a href="Delegate.html">Next feature (@Delegate)</a><br />
|
|
<a href="../../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright © 2009-2015 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>
|