Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Plushnikov committed Feb 5, 2015
1 parent 5aeb591 commit f35d008
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -25,7 +25,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>

<lombok.version>1.14.8</lombok.version>
<lombok.version>1.16.0</lombok.version>
<lombok-pg.version>0.11.3</lombok-pg.version>
<hrisey.version>0.1.1</hrisey.version>
</properties>
Expand Down
@@ -1,6 +1,6 @@
package de.plushnikov.builder;

import lombok.experimental.Builder;
import lombok.Builder;

@Builder
public class BuilderExample {
Expand All @@ -12,5 +12,4 @@ public static void main(String[] args) {
BuilderExample.builder().name("fsdf").age(23).name("123123").build();
System.out.println(example);
}

}
@@ -0,0 +1,16 @@
package de.plushnikov.builder;

import lombok.experimental.Builder;

@Builder
public class BuilderExperimentalExample {
private String name;
private int age;

public static void main(String[] args) {
BuilderExperimentalExample example = BuilderExperimentalExample.builder().age(123).name("Hallo").build();
BuilderExperimentalExample.builder().name("fsdf").age(23).name("123123").build();
System.out.println(example);
}

}
Expand Up @@ -16,6 +16,6 @@ public static void main(String[] args) {
ValueBuilder builder = new ValueBuilder("1", 2, 3.0);
System.out.println(builder);
System.out.println("Constructors: ");
Arrays.stream(ValueBuilder.class.getDeclaredConstructors()).forEach(System.out::println);
// Arrays.stream(ValueBuilder.class.getDeclaredConstructors()).forEach(System.out::println);
}
}
@@ -0,0 +1,27 @@
package de.plushnikov.sneakythrows;

import lombok.SneakyThrows;
import java.io.IOException;
public class BugReport {
private IInner inner;

//@SneakyThrows(IOException.class)
public BugReport() {
inner = new IInner() {
@SneakyThrows(IOException.class)
@Override
public IInner doSomething() {
System.out.println();
throw new IOException();
}
};
}

interface IInner {
public IInner doSomething() throws IOException;
}

public static void main(String[] args) {
System.out.println(new BugReport().toString());
}
}
36 changes: 18 additions & 18 deletions test-manual/lombok/src/main/java/de/plushnikov/val/ValComplex.java
Expand Up @@ -3,22 +3,22 @@
import lombok.val;

public class ValComplex {
private String field = "";
private static final int CONSTANT = 20;
public void testComplex() {
val shouldBeCharArray = field.toCharArray();
val shouldBeInt = CONSTANT;
val lock = new Object();
synchronized (lock) {
val field = 20; //Shadowing
val inner = 10;
switch (field) {
case 5:
val shouldBeCharArray2 = shouldBeCharArray;
val innerInner = inner;
}
}
val shouldBeString = field; //Unshadowing
}
private String field = "";
private static final int CONSTANT = 20;

public void testComplex() {
val shouldBeCharArray = field.toCharArray();
val shouldBeInt = CONSTANT;
val lock = new Object();
synchronized (lock) {
val field = 20; //Shadowing
val inner = 10;
switch (field) {
case 5:
val shouldBeCharArray2 = shouldBeCharArray;
val innerInner = inner;
}
}
val shouldBeString = field; //Unshadowing
}
}
Expand Up @@ -5,13 +5,15 @@ public void easyLub() {
java.util.Map<String, Number> m = java.util.Collections.emptyMap();

lombok.val foo = (System.currentTimeMillis() > 0) ? m : java.util.Collections.<String, Number>emptyMap();
System.out.println(foo);
}

public void sillyLubWithUnboxingThatProducesErrorThatVarIsPrimitive() {
Integer i = 20;
Double d = 20.0;

lombok.val thisShouldBePrimitiveDouble = (System.currentTimeMillis() > 0) ? i : d;
System.out.println(thisShouldBePrimitiveDouble);
}

public void hardLub() {
Expand Down
Expand Up @@ -14,51 +14,54 @@ public void testGenerics() {
val shouldBeListOfStringToo = Arrays.asList("hello", "world");
val shouldBeString2 = shouldBeListOfString.get(0);
}

public void testGenericsInference() {
val huh = Collections.emptyList();
System.out.println(huh);
val huh2 = Collections.<Number>emptyList();
System.out.println(huh2);
}

public void testPrimitives() {
val x = 10;
val y = 5 + 3L;
}

public void testAnonymousInnerClass() {
val y = new Runnable() {
public void run() {}
};
}


// public void testAnonymousInnerClass() {
// val y = new Runnable() {
// public void run() {}
// };
// System.out.println(y);
// }

public <T extends Number> void testTypeParams(List<T> param) {
val t = param.get(0);
val z = fieldList.get(0);
// val t = param.get(0);
// val z = fieldList.get(0);
val k = param;
val y = fieldList;
}
public void testBounds(List<? extends Number> lower, List<? super Number> upper) {
val a = lower.get(0);
val b = upper.get(0);
val c = lower;
val d = upper;
List<?> unbound = lower;
val e = unbound;
}
public void testCompound() {
val a = new ArrayList<String>();
val b = new Vector<String>();
val c = 1 < System.currentTimeMillis();
val d = c ? a : b;
RandomAccess confirm = c ? a : b;
}
//
// public void testBounds(List<? extends Number> lower, List<? super Number> upper) {
// val a = lower.get(0);
// val b = upper.get(0);
// val c = lower;
// val d = upper;
// List<?> unbound = lower;
// val e = unbound;
// }
//
// public void testCompound() {
// val a = new ArrayList<String>();
// val b = new Vector<String>();
// val c = 1 < System.currentTimeMillis();
// val d = c ? a : b;
// RandomAccess confirm = c ? a : b;
// }
//
public void nullType() {
val nully = null;
}

public void testArrays() {
val intArray = new int[] {1, 2, 3};
val multiDimArray = new Object[][] {{}};
Expand Down
2 changes: 1 addition & 1 deletion test-manual/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>lombok-intellij-plugin</groupId>
<artifactId>lombok-intellij-plugin-parent</artifactId>
<version>0.6</version>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit f35d008

Please sign in to comment.