Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Boilerplate

- magst du es etwa?
Ich nicht!
Glücklicherweise gibt es aber lombok*
* http://projectlombok.org
Eine kleine Library und IDE plugin, das den Code deutlich klarer macht!
Die entscheidende Frage: Benutzt ihr lombok?
... und eclipse?

Someexamplesplease!

@Getter

Erzeugt entsprechende get-Methoden.

@Getter
private final String name;
public String getName(){
return this.name;
}

@Getter(lazy=true)

Threadsafe lazy-getter

@Getter(lazy=true)
private final String name = calculateTheName();

@Setter

Erzeugt entsprechende set-Methoden.
Berücksichtigt @NotNull

@Setter @NotNull
private final String name;
public void setName(String name){
if(name==null) throw new NullPointerException(); this.name=name;
}

Konstruktoren

@AllArgsConstructor
@NoArgsConstructor
@RequiredArgsConstructor

(staticName="of")

@AllArgsConstructor(staticName="of")
public class Talk{
private final String name;
public static Talk of(String name){return new Talk(name);}
}

@EqualsAndHashCode

Generiert equals(Object o) & hashCode()
-> Joshua Bloch style ;)

@ToString

Generiert die toString() Methode.

@Data

- perfektes POJO
Kombiniert:

@ToString, @EqualsAndHashCode, @Getter, @Setter, @RequiredArgsConstructor

@Log

Support für die vier gängigen Logger
(@CommonsLog, @Log, @Log4j, @Slf4j)

private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(this.getClass());

@Delegate

Composition over inheritance without boilerplate.

@Data
public class MyMagicList<E> implements List<E>{
(...)
@Delegate @Getter(value=AccessLevel.NONE)
private final ArrayList<E> delegate = new ArrayList<E>();
}

val

Final local variables

val map = new HashMap<String, List>();
for(val entry : map.entrySet())
System.out.println("Entries per key: "+entry.getKey()+" "+entry.getValue().size());

Live coding anyone?

Use a spacebar or arrow keys to navigate