Pokazywanie postów oznaczonych etykietą java 7. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą java 7. Pokaż wszystkie posty

czwartek, 23 czerwca 2011

Spice up your Java with Lombok

Verbosity of Java language has been discussed for years. Almost since inception developers keen on clean and concise code were complaining about writing resource management code (lengthy if-try-catch with JDBC) or creating getters/mutators in Java beans. Simply put, Java language forces devs to write lots of boilerplate code. Some most painful spots are being addressed by language enhancements, like Automatic Resource Management (ARM) in Java 7. Yet this process is complex, cumbersome and takes time.
Is there any better (faster) relieve then? It seems there is! Presenting Project Lombok. Nice utility to speed-up development using source-code annotations. Some most useful features are as follows:
  • @Getter/@Setter - simply annotate any field to have appropriate method generated. What's more, getter can be "lazy" without any explicit locking code.
  • @Cleanup - ARM is here, no need to wait for version 7 release.
  • @NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor - used along with @NotNull instruct Lombok to generate appropriate constructors with arguments checking. Beautiful :)
Full list can be found here.

To entice you more, just take a look at following example:
@RequiredArgsConstructor(staticName = "of")
@AllArgsConstructor
public class Bean {

    @NotNull @Getter private String name;
    @Getter @Setter private String value;
    @Getter @Setter private int count; 
}
Isn't that appealing? ;-)

wtorek, 19 października 2010

Java 7 Coin - examples

One year ago I wrote a post about Java 7 extensions proposed by the Project Coin. Those 6 new language features were then described in long text documents. Now, with recent JDK 7 builds we're given an opportunity to test them "in fight".
I found following two interesting posts on Arul's blog filled with quick-start examples:

poniedziałek, 27 września 2010

Inception in Java - coming soon ;)

I take that almost everyone has already seen the "Inception". Some people deem it incredibly interesting, others say it's just another action movie without any "real" depth. But I guess that there is only one person in the world, that tried to write down "Inception" script in Java 7 ;-) The name is Joseph Darcy - just take a look at his blog.
While this *may* look a bit funny, in fact it's very pretty demonstration of the new try-with-resources statement. For more details take a look at the example IO code here.

czwartek, 8 października 2009

Java 7 Coin proposals

I've just found out that Coin project has released final list of Java 7 proposals! You can find them on Joseph Darcy's blog. Among others, list includes few very interesting (from Java dev point of view) things:
Unfortunately, both closures and improved exception handling were dropped from Java 7. Well, maybe next time... Still, enhancements coming with Java 7 seems to be great and - what's important - concentrated on relieving the typical pain of a Java programmer. Keep it that way!