or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

builder-pattern.mdconstructors.mddata-classes.mdexperimental.mdimmutable-patterns.mdindex.mdlogging.mdobject-methods.mdproperty-access.mdtype-inference.mdutilities.md
tile.json

tessl/maven-lombok

Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java. Never write another getter or equals method again, with one annotation your class has a fully featured builder, automate your logging variables, and much more.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.projectlombok/lombok@1.18.x

To install, run

npx @tessl/cli install tessl/maven-lombok@1.18.0

index.mddocs/

Project Lombok

Project Lombok is a comprehensive Java annotation processing library that dramatically reduces boilerplate code by automatically generating common methods and patterns at compile time. It integrates seamlessly with IDEs and build tools, generating code during compilation without affecting runtime performance.

Package Information

  • Package Name: lombok
  • Package Type: maven
  • Language: Java
  • Installation: Add to Maven/Gradle dependencies and configure annotation processing
  • Version: 1.18.40

Core Imports

// Core annotations
import lombok.*;

// Data class annotations
import lombok.Data;
import lombok.Value;

// Property access
import lombok.Getter;
import lombok.Setter;

// Constructors
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;

// Builder pattern
import lombok.Builder;
import lombok.Singular;

// Object methods
import lombok.ToString;
import lombok.EqualsAndHashCode;

// Immutable patterns
import lombok.With;

// Utility annotations
import lombok.NonNull;
import lombok.SneakyThrows;
import lombok.Synchronized;
import lombok.Cleanup;
import lombok.Locked;

// Type inference
import lombok.val;
import lombok.var;

// Logging frameworks
import lombok.extern.slf4j.Slf4j;
import lombok.extern.log4j.Log4j2;
import lombok.extern.java.Log;
import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.jbosslog.JBossLog;
import lombok.extern.flogger.Flogger;

// Jackson integration
import lombok.extern.jackson.Jacksonized;

// Experimental features
import lombok.experimental.*;
import lombok.experimental.SuperBuilder;
import lombok.experimental.UtilityClass;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.Accessors;

Basic Usage

import lombok.Data;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

@Data
@Builder
@Slf4j
public class User {
    private final String name;
    private int age;
    private String email;
    
    public void greet() {
        log.info("Hello, I'm {}", name);
    }
}

// Usage
User user = User.builder()
    .name("John Doe")
    .age(30)
    .email("john@example.com")
    .build();
    
System.out.println(user.getName()); // Generated getter
user.setAge(31); // Generated setter
log.info(user.toString()); // Generated toString

Architecture

Project Lombok is built around several key architectural components:

  • Annotation Processing: Uses Java's annotation processing API to generate code at compile time
  • AST Transformation: Modifies the Abstract Syntax Tree during compilation to add methods
  • IDE Integration: Provides plugins for Eclipse, IntelliJ IDEA, and NetBeans for editor support
  • Configuration System: Supports lombok.config files for project-wide settings
  • Type Safety: Maintains full type safety and generic type preservation
  • Compile-Time Generation: All code generation happens during compilation, not at runtime

Capabilities

Data Class Generation

Comprehensive data class support with automatic generation of getters, setters, constructors, and object methods.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Data {
    String staticConstructor() default "";
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Value {
    String staticConstructor() default "";
}

Data Classes

Property Access

Automatic generation of getter and setter methods with configurable access levels and lazy evaluation support.

@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface Getter {
    AccessLevel value() default AccessLevel.PUBLIC;
    AnyAnnotation[] onMethod() default {};
    boolean lazy() default false;
}

@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface Setter {
    AccessLevel value() default AccessLevel.PUBLIC;
    AnyAnnotation[] onMethod() default {};
    AnyAnnotation[] onParam() default {};
}

Property Access

Constructor Generation

Automatic constructor generation with support for required arguments, all arguments, and no-argument constructors.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface NoArgsConstructor {
    String staticName() default "";
    AnyAnnotation[] onConstructor() default {};
    AccessLevel access() default AccessLevel.PUBLIC;
    boolean force() default false;
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface AllArgsConstructor {
    String staticName() default "";
    AnyAnnotation[] onConstructor() default {};
    AccessLevel access() default AccessLevel.PUBLIC;
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface RequiredArgsConstructor {
    String staticName() default "";
    AnyAnnotation[] onConstructor() default {};
    AccessLevel access() default AccessLevel.PUBLIC;
}

Constructors

Builder Pattern

Comprehensive builder pattern implementation with support for inheritance, defaults, and collection handling.

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.SOURCE)
public @interface Builder {
    String builderMethodName() default "builder";
    String buildMethodName() default "build";
    String builderClassName() default "";
    boolean toBuilder() default false;
    AccessLevel access() default AccessLevel.PUBLIC;
    String setterPrefix() default "";
}

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.SOURCE)
public @interface Singular {
    String value() default "";
    boolean ignoreNullCollections() default false;
}

Builder Pattern

Object Methods

Automatic generation of toString, equals, and hashCode methods with extensive customization options.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface ToString {
    boolean includeFieldNames() default true;
    String[] exclude() default {};
    String[] of() default {};
    boolean callSuper() default false;
    boolean doNotUseGetters() default false;
    boolean onlyExplicitlyIncluded() default false;
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface EqualsAndHashCode {
    String[] exclude() default {};
    String[] of() default {};
    boolean callSuper() default false;
    boolean doNotUseGetters() default false;
    CacheStrategy cacheStrategy() default CacheStrategy.NEVER;
    AnyAnnotation[] onParam() default {};
    boolean onlyExplicitlyIncluded() default false;
}

Object Methods

Logging Integration

Seamless integration with popular Java logging frameworks through field generation.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Slf4j {
    String topic() default "";
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Log4j2 {
    String topic() default "";
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface CustomLog {
    String topic() default "";
}

Logging

Utility Annotations

Practical utilities for common programming tasks including null checking, exception handling, and synchronization.

@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
public @interface NonNull {
}

@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.SOURCE)
public @interface SneakyThrows {
    Class<? extends Throwable>[] value() default java.lang.Throwable.class;
}

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface Synchronized {
    String value() default "";
}

@Target(ElementType.LOCAL_VARIABLE)
@Retention(RetentionPolicy.SOURCE)
public @interface Cleanup {
    String value() default "close";
}

Utilities

Type Inference

Local variable type inference for cleaner, more readable code.

public final class val {
    private val() {}
}

public final class var {
    private var() {}
}

Type Inference

Immutable Patterns

Generate immutable "wither" methods that create copies of objects with modified field values.

@Target({ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface With {
    AccessLevel value() default AccessLevel.PUBLIC;
    AnyAnnotation[] onMethod() default {};
    AnyAnnotation[] onParam() default {};
}

Immutable Patterns

Experimental Features

Advanced and experimental features including utility classes, field name constants, and enhanced builder patterns.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface SuperBuilder {
    String builderMethodName() default "builder";
    String buildMethodName() default "build";
    boolean toBuilder() default false;
    String setterPrefix() default "";
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface UtilityClass {
}

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface FieldNameConstants {
    AccessLevel level() default AccessLevel.PUBLIC;
    boolean asEnum() default false;
    String innerTypeName() default "Fields";
    boolean onlyExplicitlyIncluded() default false;
}

Experimental Features

Types

public enum AccessLevel {
    PUBLIC, MODULE, PROTECTED, PACKAGE, PRIVATE, NONE
}

public enum CacheStrategy {
    NEVER, LAZY
}

public final class ConfigurationKeys {
    // Configuration key constants for lombok.config
}

public final class Lombok {
    /**
     * Throws any throwable 'sneakily' - you don't need to catch it, nor declare that you throw it onwards.
     * The exception is still thrown - javac will just stop whining about it.
     */
    public static RuntimeException sneakyThrow(Throwable t);
    
    /**
     * Returns the parameter directly.
     * This method can be used to prevent a static analyzer to determine the nullness of the passed parameter.
     */
    public static <T> T preventNullAnalysis(T value);
    
    /**
     * Ensures that the value is not null.
     * @throws NullPointerException with the message if the value is null.
     */
    public static <T> T checkNotNull(T value, String message);
}