From 4fbbd8ed03f7963715bc6e7c7de6faae0b1ba917 Mon Sep 17 00:00:00 2001 From: Bulgakov Alexander Date: Mon, 31 Oct 2016 23:52:20 +0300 Subject: added var.html --- buildScripts/website.ant.xml | 3 + usage_examples/experimental/varExample_post.jpage | 21 ++++++ usage_examples/experimental/varExample_pre.jpage | 21 ++++++ website/features/experimental/index.html | 2 + website/features/experimental/var.html | 83 +++++++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 usage_examples/experimental/varExample_post.jpage create mode 100644 usage_examples/experimental/varExample_pre.jpage create mode 100644 website/features/experimental/var.html diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index aae2285f..19b995d3 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -154,6 +154,9 @@ such as converting the changelog into HTML, and creating javadoc. + + + diff --git a/usage_examples/experimental/varExample_post.jpage b/usage_examples/experimental/varExample_post.jpage new file mode 100644 index 00000000..25623510 --- /dev/null +++ b/usage_examples/experimental/varExample_post.jpage @@ -0,0 +1,21 @@ +import java.util.ArrayList; +import lombok.var; + +public class ValExample { + public String example() { + ArrayList example = new ArrayList(); + example.add("Hello, World!"); + final String foo = example.get(0); + return foo.toLowerCase(); + } + + public void example2() { + ArrayList list = new ArrayList(); + list.add("zero"); + list.add("one"); + list.add("two"); + for(int i = 0; i < list.size(); ++i) { + System.out.printf("%d: %s\n", i, list.get(i)); + } + } +} diff --git a/usage_examples/experimental/varExample_pre.jpage b/usage_examples/experimental/varExample_pre.jpage new file mode 100644 index 00000000..0786c0df --- /dev/null +++ b/usage_examples/experimental/varExample_pre.jpage @@ -0,0 +1,21 @@ +import java.util.ArrayList; +import lombok.var; + +public class ValExample { + public String example() { + var example = new ArrayList(); + example.add("Hello, World!"); + final var foo = example.get(0); + return foo.toLowerCase(); + } + + public void example2() { + var list = new ArrayList(); + list.add("zero"); + list.add("one"); + list.add("two"); + for(var i = 0; i < list.size(); ++i) { + System.out.printf("%d: %s\n", i, list.get(i)); + } + } +} diff --git a/website/features/experimental/index.html b/website/features/experimental/index.html index f3893674..4a6d12bb 100644 --- a/website/features/experimental/index.html +++ b/website/features/experimental/index.html @@ -22,6 +22,8 @@ Features that receive positive community feedback and which seem to produce clean, flexible code will eventually become accepted as a core feature and move out of the experimental package.
+
@var
+
The same as @val but modifiable.
@Accessors
A more fluent API for getters and setters.
@ExtensionMethod
diff --git a/website/features/experimental/var.html b/website/features/experimental/var.html new file mode 100644 index 00000000..7a045c00 --- /dev/null +++ b/website/features/experimental/var.html @@ -0,0 +1,83 @@ + + + + + + + + EXPERIMENTAL – @var +
+
+
+ +

@var

+ +
+

Since

+

+ @var was introduced as experimental feature in lombok v1.16.11. +

+
+
+

Experimental

+

+ Experimental because: +

    +
  • This feature is very controversial.
  • +
  • There is JEP 286 that should make the @var obsolete.
  • +
Current status: uncertain - Currently we feel this feature cannot move out of experimental status. +
+
+

Overview

+

+ The @var has the same mission as the @val annotation but modifable. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Supported configuration keys:

+
+
lombok.val.flagUsage = [allow] (default: not set)
+
Lombok will flag any usage of var as a error if not configured.
+
+
+
+

Small print

+

+ For compound types, the most common superclass is inferred, not any shared interfaces. For example, bool ? new HashSet() : new ArrayList() + is an expression with a compound type: The result is both AbstractCollection as well as Serializable. The type inferred will be + AbstractCollection, as that is a class, whereas Serializable is an interface. +

+ In ambiguous cases, such as when the initializer expression is null, java.lang.Object is inferred. +

+
+
+ +
+
+
+ + + -- cgit