aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml76
-rw-r--r--usage_examples/DataExample_pre.jpage1
-rw-r--r--website/features/Data.html77
-rw-r--r--website/features/GetterSetter.html36
-rw-r--r--website/features/GetterSetterExample.pngbin76859 -> 0 bytes
-rw-r--r--website/features/features.css52
6 files changed, 233 insertions, 9 deletions
diff --git a/build.xml b/build.xml
index 7998d148..a9f21d7a 100644
--- a/build.xml
+++ b/build.xml
@@ -20,6 +20,7 @@
THE SOFTWARE.
-->
<project name="lombok" default="dist">
+ <property name="SNIPPET_TAB_STOP" value="2" />
<property name="build.compiler" value="javac1.6" />
<path id="lombok.deps.path">
<fileset dir="deps/lombok">
@@ -48,11 +49,80 @@
<delete dir="dist" quiet="true" />
</target>
+ <target name="website">
+ <mkdir dir="build/website" />
+ <copy todir="build/website">
+ <fileset dir="website">
+ <exclude name="**/*.jpage" />
+ <exclude name="**/*.svg" />
+ <exclude name="**/*.psd" />
+ <exclude name="**/*.ai" />
+ <exclude name="**/*unused*" />
+ </fileset>
+ </copy>
+ <antcall target="-integrateSnippet">
+ <param name="transformationName" value="GetterSetter" />
+ </antcall>
+ <antcall target="-integrateSnippet">
+ <param name="transformationName" value="Data" />
+ </antcall>
+ </target>
+
+ <target name="-integrateSnippet">
+ <mkdir dir="build/website" />
+ <property name="prefile" location="usage_examples/${transformationName}Example_pre.jpage" />
+ <property name="postfile" location="usage_examples/${transformationName}Example_post.jpage" />
+ <property name="htmlfile" location="website/features/${transformationName}.html" />
+ <mkdir dir="build/temp" />
+ <property name="preout" location="build/temp/pre.html" />
+ <property name="postout" location="build/temp/post.html" />
+ <java jar="deps/build/java2html.jar" fork="true">
+ <arg value="-srcfile" />
+ <arg value="${prefile}" />
+ <arg value="-targetfile" />
+ <arg value="${preout}" />
+ <arg line="-style Eclipse -converter html -tabs ${SNIPPET_TAB_STOP}" />
+ </java>
+ <java jar="deps/build/java2html.jar" fork="true">
+ <arg value="-srcfile" />
+ <arg value="${postfile}" />
+ <arg value="-targetfile" />
+ <arg value="${postout}" />
+ <arg line="-style Eclipse -converter html -tabs ${SNIPPET_TAB_STOP}" />
+ </java>
+ <loadfile property="pre" encoding="UTF-8" srcFile="${preout}">
+ <filterchain>
+ <linecontainsregexp>
+ <regexp pattern="(code>)|(font>)" />
+ </linecontainsregexp>
+ </filterchain>
+ </loadfile>
+ <loadfile property="post" encoding="UTF-8" srcFile="${postout}">
+ <filterchain>
+ <linecontainsregexp>
+ <regexp pattern="(code>)|(font>)" />
+ </linecontainsregexp>
+ </filterchain>
+ </loadfile>
+ <delete dir="build/temp" quiet="true" />
+ <copy file="${htmlfile}" todir="build/website/features" overwrite="true">
+ <filterchain>
+ <replacetokens>
+ <token key="HTML_PRE" value="${pre}" />
+ <token key="HTML_POST" value="${post}" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ </target>
+
<target name="compile">
<mkdir dir="build/lombok" />
- <!-- This version trickery is so that an eclipse running in a JVM 1.5 will run properly (It'll never touch the javac files and hence never trigger a Bad Class Version Number error
- but for javac we definitely cannot support javac 1.5, partly because they completely rewrote large swaths of javac, and partly because our injection mechanism (annotations)
- doesn't work very well on javac 1.5, hence, when using javac, we do demand you're on 1.6. -->
+ <!-- This version trickery is so that an eclipse running in a JVM 1.5 will run
+ properly (It'll never touch the javac files and hence never trigger a
+ Bad Class Version Number error, but for javac we definitely cannot support
+ javac 1.5, partly because they completely rewrote large swaths of javac,
+ and partly because our injection mechanism (annotations) doesn't work very
+ well on javac 1.5, hence, when using javac, we do demand you're on 1.6. -->
<javac srcdir="src" debug="on" destdir="build/lombok" target="1.5" excludes="lombok/javac/**">
<classpath refid="lombok.deps.path" />
<classpath refid="lombok.libs.path" />
diff --git a/usage_examples/DataExample_pre.jpage b/usage_examples/DataExample_pre.jpage
index 890e648b..775f82ed 100644
--- a/usage_examples/DataExample_pre.jpage
+++ b/usage_examples/DataExample_pre.jpage
@@ -2,7 +2,6 @@ import lombok.AccessLevel;
import lombok.Setter;
import lombok.Data;
-@lombok.core.PrintAST(printContent=true)
public @Data class DataExample {
private final String name;
private @Setter(AccessLevel.PACKAGE) int age;
diff --git a/website/features/Data.html b/website/features/Data.html
new file mode 100644
index 00000000..3a9697cc
--- /dev/null
+++ b/website/features/Data.html
@@ -0,0 +1,77 @@
+<!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>@Data</title>
+ <!--[if lt IE 7]><script type="text/javascript" src="logi/iepngfix_tilebg.js"></script><![endif]-->
+</head><body><div id="pepper">
+ <div class="meat">
+ <div class="minimumHeight"></div>
+ <div class="header"><a href="../index.html">Project Lombok</a></div>
+ <h1>@Data</h1>
+ <div class="overview">
+ <h3>Overview</h3>
+ <p>
+ Any class definition may be annotated with <code>@Data</code> to let lombok generate all the boilerplate that is associated with simple POJOs
+ (Plain Old Java Objects) and beans: getters for all fields, setters for all non-final fields, a useful <code>toString</code>, and implementations
+ of <code>hashCode</code> and <code>equals</code> which consider any two objects of this type with the same values for each field as equal. A
+ constructor is also generated containing 1 parameter for each final field, in the order the fields are defined. This constructor simply assigns
+ each parameter to the appropriate field.
+ </p>
+ <p>
+ To override the access level of any getter/setter for any field, annotate the field with a <code>@Setter</code> or <code>@Getter</code> annotation
+ with the appropriate <code>AccessLevel</code> value. See the example below. For more information on how the getters/setters are generated,
+ see the documentation for <a href="GetterSetter.html"><code>@Getter</code> and <code>@Setter</code></a>.
+ </p><p>
+ All fields marked as <code>transient</code> will not be considered for <code>hashCode</code> and <code>equals</code>. All static fields will be
+ skipped entirely (not considered for any of the generated methods, and no setter/getter will be made for them).
+ The generated getter/setter method will be <code>public</code> unless you explicitly specify an <code>AccessLevel</code>, as shown in the example below.
+ Legal access levels are <code>PUBLIC</code>, <code>PROTECTED</code>, <code>PACKAGE</code>, and <code>PRIVATE</code>.
+ </p><p>
+ If any method that would normally be generated exists <em>in name</em> that method will not be generated, and no warning or error is emitted. For example,
+ if you already have a method with signature <code>void hashCode(int a, int b, int c)</code>, no <code>int hashCode()</code> method will be generated,
+ even though technically <code>int hashCode()</code> is an entirely different method. The same rule applies to the constructor, <code>toString</code>,
+ <code>hashCode</code>, and all getters and setters.
+ </p><p>
+ <code>@Data</code> can handle generics parameters for fields just fine. In order to reduce the boilerplate when constructing objects for classes with
+ generics, you can use the <code>staticConstructor</code> parameter to generate a private constructor, as well as a static method that returns a new
+ instance. This way, javac will infer the variable name. Thus, by declaring like so: <code>@Data(staticConstructor="of") class Foo&lt;T&gt; { private T x;}</code>
+ you can create new instances of <code>Foo</code> by writing: <code>Foo.of(5);</code> instead of having to write: <code>new Foo&lt;Integer&gt;(5);</code>.
+ </p>
+ <h3>Small print</h3><div class="smallprint">
+ <p>
+ Arrays are 'deep' compared/printed/hashCoded, 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>
+ You may safely presume that the hashCode implementation used will not change between versions of lombok, however this guarantee is not set in stone;
+ if there's a significant performance improvement to be gained from using an alternate hash algorithm, that will be substituted in a future version.
+ </p><p>
+ For a general idea of how lombok generated the <code>equals</code>, <code>hashCode</code>, and <code>toString</code> methods, check the example below.
+ </p><p>
+ For the purposes of equality, 2 <code>NaN</code> (not a number) values for floats and doubles are considered equal, eventhough 'NaN == NaN' would
+ return false. This is analogous to <code>java.lang.Double</code>'s equals method, and is in fact required to ensure that comparing an object
+ to an exact copy of itself returns <code>true</code> for equality.
+ </p>
+ </div>
+ </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>
+ <footer>
+ <a href="features.html">Back to features</a> | <a href="GetterSetter.html">Previous feature (@Getter / @Setter)</a> | <a href="Cleanup.html">Next feature (@Cleanup)</a><br />
+ <span class="copyright">Copyright &copy; 2009 Reinier Zwitserloot and Roel Spilker, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT licence</a>.</span>
+ </footer>
+ <div style="clear: both;"></div>
+ </div>
+</div></body></html>
diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html
index 246a8eab..d8ffbb6a 100644
--- a/website/features/GetterSetter.html
+++ b/website/features/GetterSetter.html
@@ -1,8 +1,6 @@
<!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="features.js" type="text/javascript"></script>
<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" />
@@ -15,6 +13,40 @@
<div class="header"><a href="../index.html">Project Lombok</a></div>
<h1>@Getter and @Setter</h1>
<div class="overview">
+ <h3>Overview</h3>
+ <p>
+ You can annotate any field with <code>@Getter</code> and/or <code>@Setter</code>, to let lombok generate the default getter/setter automatically.<br />
+ A default getter simply returns the field, and is named <code>getFoo</code> if the field is called <code>foo</code> (or <code>isFoo</code>)
+ if the field's type is <code>boolean</code>. A default setter is named <code>setFoo</code> if the field is called <code>foo</code>, returns <code>void</code>,
+ and takes 1 parameter of the same type as the field. It simply sets the field to this value.
+ </p><p>
+ The generated getter/setter method will be <code>public</code> unless you explicitly specify an <code>AccessLevel</code>, as shown in the example below.
+ Legal access levels are <code>PUBLIC</code>, <code>PROTECTED</code>, <code>PACKAGE</code>, and <code>PRIVATE</code>.
+ </p>
+ <h3>Small print</h3><div class="smallprint">
+ <p>
+ For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified.
+ Then, get/set/is is prefixed.
+ </p><p>
+ No method is generated if any method already exists with the same name, even if the parameter list is different. For example, <code>getFoo()</code>
+ will not be generated if there's already a method <code>getFoo(int x)</code> even though it is technically possible to make the method. This caveat
+ exists to prevent confusion. If the generation of a method is skipped for this reason, a warning is emitted instead.
+ </p><p>
+ Any variation on <code>boolean</code> will <em>not</em> result in using the <code>is</code> prefix instead of the <code>get</code> prefix; for example,
+ returning <code>java.lang.Boolean</code> results in a <code>get</code> prefix, not an <code>is</code> prefix.
+ </p>
+ </div>
+ </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>
<footer>
<a href="features.html">Back to features</a> | <span class="disabled">Previous feature</span> | <a href="Data.html">Next feature (@Data)</a><br />
diff --git a/website/features/GetterSetterExample.png b/website/features/GetterSetterExample.png
deleted file mode 100644
index 785a5984..00000000
--- a/website/features/GetterSetterExample.png
+++ /dev/null
Binary files differ
diff --git a/website/features/features.css b/website/features/features.css
index e7bbdeca..4f8fe468 100644
--- a/website/features/features.css
+++ b/website/features/features.css
@@ -25,7 +25,7 @@ body {
.meat .minimumHeight {
height: 700px;
width: 5px;
- float: left;
+ float: right;
}
h1 {
@@ -33,9 +33,55 @@ h1 {
text-align: center;
}
+.overview code {
+ font-size: 1.2em;
+}
+
+.snippets {
+ margin-top: 32px;
+}
+
+.snippets .pre {
+ white-space: pre;
+ float: left;
+ width: 45%;
+}
+
+.snippet {
+ overflow: auto;
+ padding: 4px;
+ border: 1px dotted #888;
+}
+
+.snippets .sep {
+ display: block;
+ width: 5%;
+ height: 1px;
+ float: left;
+}
+
+.snippets .post {
+ white-space: pre;
+ float: left;
+ width: 45%;
+}
+
+.snippets .end {
+ clear: both;
+}
+
+.snippet code {
+ font-size: 14px;
+}
+
+.snippet br {
+ display: none;
+}
+
footer {
- margin: 64px auto 0 auto;
- padding-bottom: 16px;
+ clear: left;
+ margin: 0 auto 0 auto;
+ padding: 16px 0 16px 0;
display: block;
text-align: center;
}