diff options
author | Bulgakov Alexander <abulgakov@at-consulting.ru> | 2016-10-20 16:41:40 +0300 |
---|---|---|
committer | Bulgakov Alexander <abulgakov@at-consulting.ru> | 2016-10-24 16:28:02 +0300 |
commit | 55619e8030768fb42f8a9b4207bb330806eaceef (patch) | |
tree | 1b46b9ed40a2b03aae727a3a5900ec6356a2a82d /test/transform/resource/before | |
parent | 4d9da60f4f2643302e53267ef150ee4c68c39d7c (diff) | |
download | lombok-55619e8030768fb42f8a9b4207bb330806eaceef.tar.gz lombok-55619e8030768fb42f8a9b4207bb330806eaceef.tar.bz2 lombok-55619e8030768fb42f8a9b4207bb330806eaceef.zip |
added supporting of @var variables. The @var annotation has the same functionality as the @val except 'final' modifier.
Diffstat (limited to 'test/transform/resource/before')
-rw-r--r-- | test/transform/resource/before/VarComplex.java | 22 | ||||
-rw-r--r-- | test/transform/resource/before/VarInFor.java | 11 | ||||
-rw-r--r-- | test/transform/resource/before/VarInForOld.java | 9 | ||||
-rw-r--r-- | test/transform/resource/before/VarModifier.java | 10 |
4 files changed, 52 insertions, 0 deletions
diff --git a/test/transform/resource/before/VarComplex.java b/test/transform/resource/before/VarComplex.java new file mode 100644 index 00000000..c93e177a --- /dev/null +++ b/test/transform/resource/before/VarComplex.java @@ -0,0 +1,22 @@ +import lombok.var; + +public class VarComplex { + private String field = ""; + private static final int CONSTANT = 20; + + public void testComplex() { + var shouldBeCharArray = field.toCharArray(); + var shouldBeInt = CONSTANT; + var lock = new Object(); + synchronized (lock) { + var field = 20; //Shadowing + var inner = 10; + switch (field) { + case 5: + var shouldBeCharArray2 = shouldBeCharArray; + var innerInner = inner; + } + } + var shouldBeString = field; //Unshadowing + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarInFor.java b/test/transform/resource/before/VarInFor.java new file mode 100644 index 00000000..7f7bb7a7 --- /dev/null +++ b/test/transform/resource/before/VarInFor.java @@ -0,0 +1,11 @@ +import lombok.var; + +public class VarInFor { + public void enhancedFor() { + int[] list = new int[] {1, 2}; + for (var shouldBeInt : list) { + System.out.println(shouldBeInt); + var shouldBeInt2 = shouldBeInt; + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarInForOld.java b/test/transform/resource/before/VarInForOld.java new file mode 100644 index 00000000..99e83b57 --- /dev/null +++ b/test/transform/resource/before/VarInForOld.java @@ -0,0 +1,9 @@ +import lombok.var; + +public class VarInForOld { + public void oldFor() { + for (var i = 0; i < 100; ++i) { + System.out.println(i); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/VarModifier.java b/test/transform/resource/before/VarModifier.java new file mode 100644 index 00000000..bb167fd2 --- /dev/null +++ b/test/transform/resource/before/VarModifier.java @@ -0,0 +1,10 @@ +import lombok.var; + +public class VarModifier { + private String field = ""; + + public void testComplex() { + final var shouldBeFinalCharArray = field.toCharArray(); + var shouldBeCharArray = field.toCharArray(); + } +}
\ No newline at end of file |