1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="logi/jQuery-all.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="logi/reset.css" />
<link rel="stylesheet" type="text/css" href="index.css" />
<link rel="stylesheet" type="text/css" href="slideshow/slideshow.css" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<meta name="description" content="Spice up your java" />
<title>Project Lombok</title>
<!--[if lt IE 7]><script type="text/javascript" src="logi/iepngfix_tilebg.js"></script><![endif]-->
</head><body>
<a id="forkMe" href="http://github.com/rzwitserloot/lombok"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div class="meat">
<h1>Project Lombok</h1>
<div id="downloadInfo" class="buttonBar" style="display: none;">
<span></span>
<div class="downloadActions">
<a class="backToBar" href="http://projectlombok.googlecode.com/files/lombok.jar">Okay, download <strong>lombok</strong></a>
<a href="#" class="backToBar">No, don't</a>
</div>
</div>
<div id="buttonBar" class="buttonBar">
<a class="button" href="features/index.html">
<img src="icon_overview.png" />
<span>Feature Overview</span>
</a>
<a class="button" href="http://groups.google.com/group/project-lombok">
<img src="icon_discussion.png" />
<span>Discuss / Help</span>
</a>
<a class="button" href="http://wiki.github.com/rzwitserloot/lombok/contributing">
<img src="icon_contribute.png" />
<span>Contribute</span>
</a>
<a class="button" href="http://code.google.com/p/projectlombok/issues/list">
<img src="icon_bugs.png" />
<span>Report an issue</span>
</a>
<a class="download" id="downloadLink" href="download.html">
<img src="icon_download.png" />
<span>Download!</span>
</a>
</div>
<div class="slideshow">
<div class="para">
Imagine you have a very simple class:
</div><div class="snippet">public class Mountain {
private final String name;
private final double latitude, longitude;
private String country;
}</div>
<div class="para">
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">
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">
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">
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">
<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">
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">
Thanks for checking out Project Lombok, and let us know what you think!
</div>
</div>
<div class="endBar">
<a href="index.html">I changed my mind - I do want to see the video!</a>
</div>
<div class="footer">
<a href="credits.html" class="creditsLink">credits</a> | Copyright © 2009 Reinier Zwitserloot and Roel Spilker, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT licence</a>.
</div>
</div>
</body></html>
|