mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 14:17:48 +00:00
Changes 'div class=para' to the simpler and semantically correct 'p'.
This commit is contained in:
1 parent
70fb2fe83f
commit
63aceae8be
2 files changed
+9
-9
No files matched your search
@@ -56,39 +56,39 @@
|
||||
private final double latitude, longitude;
|
||||
private String country;
|
||||
}</div>
|
||||
<div class="para">
|
||||
<p>
|
||||
While that is fairly clear, that class is not complete. In fact, it won't compile like that.<br />
|
||||
You'll need to add a constructor to initialize those final fields, you probably want getters, a setter for <code>country</code>,
|
||||
and to be complete, a nice <code>toString</code> as well as an implementation for <code>equals</code> and <code>hashCode</code>.
|
||||
Eclipse can generate all these methods for you, but then you end up with over 70 lines of boilerplate. It's going to be hard
|
||||
to see any surprises buried amongst all those lines of code! Lombok has the answer to this problem.
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
So instead of this mess:
|
||||
<img class="screenshot" src="slideshow/eclipse-generate.png" />
|
||||
lombok simply offers you an annotation that tells eclipse to generate all this stuff for us silently, without
|
||||
cluttering up your source file, like so:
|
||||
<img class="screenshot" src="slideshow/eclipse-lombok.png" />
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
Note how we haven't even saved the file yet, but in the outline view you can already see all the various methods generated
|
||||
by the <code>@Data</code> annotation. That's because lombok is completely integrated into eclipse. The moment you type
|
||||
the last character of your annotation, all the methods exist, just as if you write the last character on a method declaration.
|
||||
In other words, lombok is <em>not</em> just an annotation processor!
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
But what about your build process? Lombok works just as well in <strong>javac</strong>. All you need to do is add
|
||||
<code>lombok.jar</code> to the class path as you compile. Like so:
|
||||
<img class="screenshot" src="slideshow/javac.png" />
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
<code>@Data</code> is nice, but its certainly not the only boilerplate buster that lombok has to offer. If you need
|
||||
more fine grained control, there's <code>@Getter</code> and <code>@Setter</code>, and to help you in correctly
|
||||
cleaning up your resources, <code>@Cleanup</code> can automatically and without cluttering your source files generate
|
||||
try/finally blocks to safely call <code>close()</code> on your resource objects. That's not all, but for the complete
|
||||
list you'll need to head over to the <a href="features/index.html">feature overview</a>.
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
Ready to install lombok? Start by clicking the download button at the top of this page. Going from clicking that button
|
||||
to having your eclipse ready to go takes less than 12 seconds - it's that simple.
|
||||
</div><div class="para">
|
||||
</p><p>
|
||||
Thanks for checking out Project Lombok, and let us know what you think!
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
<div class="endBar">
|
||||
<a href="index.html">I changed my mind - I do want to see the video!</a>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
.para {
|
||||
p {
|
||||
margin: 4px 0 4px 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user