mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-03 05:20:17 +00:00
Issue 192: Add documentation for onMethod=, onParam, onConstructor
still have to make a minor edit in the pre/post files
This commit is contained in:
1 parent
35e18b9332
commit
e0cfacd3b3
6 files changed
+128
-1
No files matched your search
@@ -144,6 +144,9 @@ such as converting the changelog into HTML, and creating javadoc.
|
||||
<antcall target="-integrateSnippet">
|
||||
<param name="transformationName" value="Delegate" />
|
||||
</antcall>
|
||||
<antcall target="-integrateSnippet">
|
||||
<param name="transformationName" value="onX" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="-website-dist">
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
public class OnMethodOnParamExample {
|
||||
private int fires = 200;
|
||||
private int firemen = 20;
|
||||
private String fireStationName = "base";
|
||||
|
||||
@Deprecated
|
||||
public int getFires() {
|
||||
return fires;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setFiremen(int firemen) {
|
||||
this.firemen = firemen;
|
||||
}
|
||||
|
||||
public void setFireStationName(@SuppressWarnings("all") int fireStationName) {
|
||||
this.fireStationName = fireStationName;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires);
|
||||
}
|
||||
}
|
||||
|
||||
class OnConstructorExample {
|
||||
private final int radishes;
|
||||
private int bananas;
|
||||
|
||||
@Deprecated
|
||||
public OnConstructorExample(int radishes) {
|
||||
this.radishes = radishes;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return String.format("I have %d bananas and %d radishes", bananas, radishes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
public class OnMethodOnParamExample {
|
||||
@Getter(onMethod=@Deprecated) private int fires = 200;
|
||||
@Setter(onMethod=@Deprecated) private int firemen = 20;
|
||||
@Setter(onParam=@SuppressWarnings("all")) private String fireStationName = "base";
|
||||
|
||||
@Override public String toString() {
|
||||
return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires);
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor(onConstructor=@Deprecated)
|
||||
class OnConstructorExample {
|
||||
private final int radishes;
|
||||
private int bananas;
|
||||
|
||||
@Override public String toString() {
|
||||
return String.format("I have %d bananas and %d radishes", bananas, radishes);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
<div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<a href="index.html">Back to features</a> | <a href="val.html">Previous feature (val)</a> | <span class="disabled">Next feature</span><br />
|
||||
<a href="index.html">Back to features</a> | <a href="val.html">Previous feature (val)</a> | <a href="onX.html">Next feature (onMethod=,onParameter=,onConstructor=)</a><br />
|
||||
<a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright © 2010-2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
<dd>Finally! hassle-free final local variables.</dd>
|
||||
<dt><a href="Delegate.html"><code>@Delegate</code></a></dt>
|
||||
<dd>Don't lose your composition</dd>
|
||||
<dt><a href="onX.html"><code>onMethod=,onParam=,onConstructor=</code></a></dt>
|
||||
<dd>Annotate this! Add you favorite annotation to methods generated by lombok.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="pointer">
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<!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>onMethod=,onParam=,onConstructor=</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>onMethod=,onParam=,onConstructor=</h1>
|
||||
<div class="byline">Annotate this! Add you favorite annotation to methods generated by lombok.</div>
|
||||
<div class="overview">
|
||||
<h3>Overview</h3>
|
||||
<p>
|
||||
Lombok lets you add your favorite annotation to methods generated by <code>@Getter</code> and <code>@Setter</code> by using the attribute <code>onMethod</code>
|
||||
on the lombok annotation. You can specify annotations to the parameters of the method on <code>@Setter</code> with the attribute <code>onParameter</code>.
|
||||
You can add annotation to constructors generated by <code>@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor</code> by using the attribute
|
||||
<code>onConstructor</code>
|
||||
</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">
|
||||
When the @Getter or @Setter annotation is placed on the type in stead of a field, using the attribute is not supported and it will result in a warning.
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<a href="index.html">Back to features</a> | <a href="Delegate.html">Previous feature (@Delegate)</a> | <span class="disabled">Next feature</span><br />
|
||||
<a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright © 2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans, 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>
|
||||
Reference in new issue
Block a user