You can edit almost every page by Creating an account and confirming your email.

Lombok (Java Library)

From EverybodyWiki Bios & Wiki






Project Lombok
Original author(s)Reinier Zwitserloot
Written inJava
Engine
    TypeJava library
    LicenseMIT License

    Search Lombok (Java Library) on Amazon.

    The Project Lombok (also known as Lombok) is a Java library and annotation processor for the Java platform. The library core features can be used by any Java application, but there are some requirements to make it work with Integrated development environments such as IntelliJ IDEA or Eclipse IDE.

    The main feature of Lombok is to automate the generation of Java Beans getters and setters by using annotations.

    Basic usage

    The basic annotations @Getter and @Setter will automatically generate accessor methods for you at the compilation time, which means you can still use setAge() and getAge() without having these methods explicitly.

    The following is a rudimentary example of a JavaBean using Lombok:

    import lombok.AccessLevel;
    import lombok.Getter;
    import lombok.Setter;
    
    public class GetterSetterExample {
      @Getter @Setter private int age = 10;
      @Setter(AccessLevel.PROTECTED) private String name;
      
      @Override
      public String toString() {
        return String.format("%s (age: %d)", name, age);
      }
    }
    

    The following is a rudimentary example of a vanilla (not using Lombok) JavaBean:

    public class GetterSetterExample {
      private int age = 10;
      private String name;
      
      @Override
      public String toString() {
        return String.format("%s (age: %d)", name, age);
      }
    
      public int getAge() {
        return age;
      }
    
      public void setAge(int age) {
        this.age = age;
      }
    
      protected void setName(String name) {
        this.name = name;
      }
    }
    

    On the compilation step, Lombok will create these mutator methods for you and the generated bytecode will be practically identical.

    References

    External links


    This article "Lombok (Java Library)" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Lombok (Java Library). Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.