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 :)
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? ;-)
2 komentarze:
Annotated getters and setters in java looks impressive, but for .NET developers it's a daily bread:
public class Person
{
public string Firstname { get; set; }
public string Middlename { get; set; }
public string Lastname { get; set; }
public int Age { get; set; }
}
Indeed, Java as a language lacks many features embraced a long time ago by other languages. On the other hand, Lombok gives much more than "standard" built-in solutions :)
Prześlij komentarz