or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/maven-org-projectlombok--lombok

A Java library that automatically plugs into your editor and build tools, reducing boilerplate code through annotations

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-org-projectlombok--lombok@1.18.0

0

# Project Lombok

1

2

Project Lombok is a Java library that automatically plugs into your editor and build tools, reducing boilerplate code through compile-time annotation processing. It eliminates the need to write repetitive code like getters, setters, constructors, equals, hashCode, and toString methods by generating them automatically at compile time through annotations.

3

4

## Package Information

5

6

- **Package Name**: lombok

7

- **Package Type**: Maven

8

- **Language**: Java

9

- **Maven Coordinates**: `org.projectlombok:lombok`

10

- **Installation**: Add to your Maven `pom.xml` or Gradle `build.gradle`

11

12

Maven:

13

```xml

14

<dependency>

15

<groupId>org.projectlombok</groupId>

16

<artifactId>lombok</artifactId>

17

<version>1.18.38</version>

18

<scope>provided</scope>

19

</dependency>

20

```

21

22

Gradle:

23

```gradle

24

dependencies {

25

compileOnly 'org.projectlombok:lombok:1.18.38'

26

annotationProcessor 'org.projectlombok:lombok:1.18.38'

27

}

28

```

29

30

## Core Imports

31

32

```java

33

import lombok.*;

34

import lombok.experimental.*;

35

import lombok.extern.slf4j.Slf4j;

36

```

37

38

Individual imports:

39

```java

40

import lombok.Data;

41

import lombok.Getter;

42

import lombok.Setter;

43

import lombok.Builder;

44

import lombok.AllArgsConstructor;

45

import lombok.NoArgsConstructor;

46

import lombok.RequiredArgsConstructor;

47

```

48

49

## Basic Usage

50

51

```java

52

import lombok.Data;

53

import lombok.NonNull;

54

55

@Data

56

public class Person {

57

@NonNull

58

private String name;

59

private int age;

60

private String email;

61

}

62

63

// Usage

64

Person person = new Person("John Doe", 30, "john@example.com");

65

System.out.println(person.getName()); // Generated getter

66

person.setAge(31); // Generated setter

67

System.out.println(person.toString()); // Generated toString

68

```

69

70

## Architecture

71

72

Lombok operates through several key mechanisms:

73

74

- **Annotation Processing**: Compile-time code generation using Java's annotation processing API

75

- **Bytecode Manipulation**: Direct bytecode modification during compilation

76

- **IDE Integration**: Plugin-based integration with major IDEs (Eclipse, IntelliJ IDEA, NetBeans)

77

- **Build Tool Support**: Integration with Maven, Gradle, and Ant build systems

78

- **Delombok**: Utility to convert lombok-annotated code to standard Java code for source inspection

79

80

## Capabilities

81

82

### Data Class Annotations

83

84

Comprehensive annotations for creating data classes with minimal boilerplate. Perfect for POJOs, DTOs, and value objects.

85

86

```java { .api }

87

@Target(ElementType.TYPE)

88

@interface Data {

89

String staticConstructor() default "";

90

}

91

92

@Target(ElementType.TYPE)

93

@interface Value {

94

String staticConstructor() default "";

95

}

96

```

97

98

[Data Class Annotations](./data-classes.md)

99

100

### Constructor Generation

101

102

Automatic constructor generation with various configurations for different use cases including dependency injection and immutable objects.

103

104

```java { .api }

105

@Target(ElementType.TYPE)

106

@interface NoArgsConstructor {

107

String staticName() default "";

108

AccessLevel access() default AccessLevel.PUBLIC;

109

boolean force() default false;

110

AnyAnnotation[] onConstructor() default {};

111

}

112

113

@Target(ElementType.TYPE)

114

@interface AllArgsConstructor {

115

String staticName() default "";

116

AccessLevel access() default AccessLevel.PUBLIC;

117

AnyAnnotation[] onConstructor() default {};

118

}

119

120

@Target(ElementType.TYPE)

121

@interface RequiredArgsConstructor {

122

String staticName() default "";

123

AccessLevel access() default AccessLevel.PUBLIC;

124

AnyAnnotation[] onConstructor() default {};

125

}

126

```

127

128

[Constructor Generation](./constructors.md)

129

130

### Property Access Generation

131

132

Getter and setter generation with access level control, lazy loading, and method annotation support.

133

134

```java { .api }

135

@Target({ElementType.FIELD, ElementType.TYPE})

136

@interface Getter {

137

AccessLevel value() default AccessLevel.PUBLIC;

138

AnyAnnotation[] onMethod() default {};

139

boolean lazy() default false;

140

}

141

142

@Target({ElementType.FIELD, ElementType.TYPE})

143

@interface Setter {

144

AccessLevel value() default AccessLevel.PUBLIC;

145

AnyAnnotation[] onMethod() default {};

146

AnyAnnotation[] onParam() default {};

147

}

148

```

149

150

[Property Access](./property-access.md)

151

152

### Builder Pattern

153

154

Fluent builder pattern implementation with support for inheritance, default values, and collection handling.

155

156

```java { .api }

157

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})

158

@interface Builder {

159

String builderMethodName() default "builder";

160

String buildMethodName() default "build";

161

String builderClassName() default "";

162

boolean toBuilder() default false;

163

AccessLevel access() default AccessLevel.PUBLIC;

164

String setterPrefix() default "";

165

}

166

167

@Target(ElementType.FIELD)

168

@interface Singular {

169

String value() default "";

170

boolean ignoreNullCollections() default false;

171

}

172

```

173

174

[Builder Pattern](./builder.md)

175

176

### Utility Annotations

177

178

Code generation for common Java patterns including null checking, exception handling, synchronization, and immutable updates.

179

180

```java { .api }

181

@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})

182

@interface NonNull {}

183

184

@Target(ElementType.METHOD)

185

@interface SneakyThrows {

186

Class<? extends Throwable>[] value() default {};

187

}

188

189

@Target(ElementType.METHOD)

190

@interface Synchronized {

191

String value() default "";

192

}

193

194

@Target({ElementType.FIELD, ElementType.TYPE})

195

@interface With {

196

AccessLevel value() default AccessLevel.PUBLIC;

197

AnyAnnotation[] onMethod() default {};

198

AnyAnnotation[] onParam() default {};

199

}

200

```

201

202

[Utility Annotations](./utilities.md)

203

204

### Logging Framework Integration

205

206

Automatic logger field generation for major Java logging frameworks with configurable topics and field names.

207

208

```java { .api }

209

@Target(ElementType.TYPE)

210

@interface Slf4j {

211

String topic() default "";

212

}

213

214

@Target(ElementType.TYPE)

215

@interface Log {

216

String topic() default "";

217

}

218

219

@Target(ElementType.TYPE)

220

@interface Log4j2 {

221

String topic() default "";

222

}

223

```

224

225

[Logging Integration](./logging.md)

226

227

### Experimental Features

228

229

Advanced and experimental features including utility classes, enhanced builders for inheritance, and field name constants.

230

231

```java { .api }

232

@Target(ElementType.TYPE)

233

@interface UtilityClass {}

234

235

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})

236

@interface SuperBuilder {

237

String builderMethodName() default "builder";

238

String buildMethodName() default "build";

239

boolean toBuilder() default false;

240

String setterPrefix() default "";

241

}

242

243

@Target({ElementType.TYPE, ElementType.FIELD})

244

@interface FieldDefaults {

245

AccessLevel level() default AccessLevel.NONE;

246

boolean makeFinal() default false;

247

}

248

```

249

250

[Experimental Features](./experimental.md)

251

252

## Types

253

254

### Core Enums

255

256

```java { .api }

257

public enum AccessLevel {

258

PUBLIC, MODULE, PROTECTED, PACKAGE, PRIVATE, NONE

259

}

260

```

261

262

### Type Inference

263

264

```java { .api }

265

// Type inference for local variables

266

lombok.val finalVar = someExpression(); // final var with inferred type

267

lombok.var mutableVar = someExpression(); // mutable var with inferred type

268

```

269

270

### Utility Classes

271

272

```java { .api }

273

public final class Lombok {

274

public static RuntimeException sneakyThrow(Throwable t);

275

public static <T> T preventNullAnalysis(T value);

276

public static <T> T checkNotNull(T reference, String errorMessage);

277

}

278

```