Przejdź do treści
Biblioteka skilli
Programowanie · Nauka i wyjaśnianie

lombok

/lombok

Opisuje Project Lombok, który ogranicza szablonowy kod w Javie: adnotacje dla getterów, setterów, konstruktorów, builderów i logowania.

Licencja
MIT
Ostatnia zmiana repozytorium
21.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
1
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • SKILL.md zawiera komentarze HTML (1). Nie widać ich w podglądzie Markdown, a model je czyta.

Co robi i kiedy

Opisuje Project Lombok, który ogranicza szablonowy kod w Javie: adnotacje dla getterów, setterów, konstruktorów, builderów i logowania.

Wyzwalacze z opisu

lombok@Data@Builder@Slf4jboilerplate reductiongetters/setters@RequiredArgsConstructor@Value
Oryginalny opis (EN)

Project Lombok for reducing Java boilerplate. Covers annotations for getters, setters, constructors, builders, logging, and more. Based on production patterns from castellino and gestionale-presenze projects. USE WHEN: user mentions "lombok", "@Data", "@Builder", "@Slf4j", asks about "boilerplate reduction", "getters/setters", "@RequiredArgsConstructor", "@Value" DO NOT USE FOR: Java language features - use `java` skill instead DO NOT USE FOR: MapStruct integration - use `mapstruct` skill DO NOT USE FOR: Spring annotations - use `backend-spring-boot` skill

Jak działa

  1. Maven Configuration
  2. Common Annotations
  3. Entity Pattern
  4. Service Pattern with Constructor Injection
  5. Logging
  6. DTO Pattern
  7. @Cleanup
  8. @SneakyThrows
  9. @Synchronized
  10. @With (Immutable Updates)
Sekcje z nagłówków SKILL.md, w oryginale · 331 linii, 911 słów
Podgląd SKILL.md
---
name: lombok
description: |
  Project Lombok for reducing Java boilerplate. Covers annotations for getters,
  setters, constructors, builders, logging, and more. Based on production
  patterns from castellino and gestionale-presenze projects.

  USE WHEN: user mentions "lombok", "@Data", "@Builder", "@Slf4j", asks about
  "boilerplate reduction", "getters/setters", "@RequiredArgsConstructor", "@Value"

  DO NOT USE FOR: Java language features - use `java` skill instead
  DO NOT USE FOR: MapStruct integration - use `mapstruct` skill
  DO NOT USE FOR: Spring annotations - use `backend-spring-boot` skill
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Project Lombok

> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `lombok` for comprehensive documentation.

## Maven Configuration

```xml
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.34</version>
    <optional>true</optional>
</dependency>

<!-- For MapStruct compatibility -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok-mapstruct-binding</artifactId>
    <version>0.2.0</version>
</dependency>
```

## Common Annotations

### @Data (All-in-One)

```java
@Data
public class User {
    private Long id;
    private String name;
    private String email;
}

// Generates:
// - @Getter for all fields
// - @Setter for all non-final fields
// - @ToString
// - @EqualsAndHashCode
// - @RequiredArgsConstructor
```

### @Getter / @Setter

```java
public class User {
    @Getter @Setter
    private String name;

    @Getter // Read-only
    private final String email;

    @Setter(AccessLevel.PROTECTED)
    private String internalId;
}
```

### @NoArgsConstructor / @AllArgsConstructor / @RequiredArgsConstructor

```java
@NoArgsConstructor
@AllArgsConstructor
public class User {
    private Long id;
    private String name;
}

@RequiredArgsConstructor
public class UserService {
    private final UserRepository userRepository; // Included in constructor
    private final UserMapper userMapper;         // Included in constructor
    private String cacheName;                    // NOT included
}
```

### @Builder

```java
@Data
@Builder
public class User {
    private Long id;
    private String name;
    private String email;
    @Builder.Default
    private UserStatus status = UserStatus.ACTIVE;
}

// Usage
User user = User.builder()
    .name("John")
    .email("john@example.com")
    .build();

// With toBuilder for updates
User updated = user.toBuilder()
    .name("Jane")
    .build();
```

### @Value (Immutable)

```java
@Value
public class UserResponse {
    Long id;
    String name;
    String email;
    LocalDateTime createdAt;
}

// Generates:
// - All fields are private final
// - @AllArgsConstructor
// - @Getter (no setters)
// - @ToString
// - @EqualsAndHashCode
```

## Entity Pattern

```java
@Entity
@Table(name = "users")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EntityListeners(AuditingEntityListener.class)
public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private String name;

    @Column(unique = true, nullable = false)
    private String email;

    @Enumerated(EnumType.STRING)
    @Builder.Default
    private UserStatus status = UserStatus.ACTIVE;

    @CreatedDate
    @Column(updatable = false)
    private LocalDateTime createdAt;

    @LastModifiedDate
    private LocalDateTime updatedAt;

    // Exclude from toString/equals for performance
    @ToString.Exclude
    @EqualsAndHashCode.Exclude
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "department_id")
    private Department department;
}
```

## Service Pattern with Constructor Injection

```java
@Service
@RequiredArgsConstructor
@Slf4j
public class UserServiceImpl implements UserService {

    private final UserRepository userRepository;
    private final UserMapper userMapper;
    private final PasswordEncoder passwordEncoder;

    @Override
    public UserResponse create(CreateUserRequest dto) {
        log.info("Creating user: {}", dto.getEmail());
        User user = userMapper.toEntity(dto);
        return userMapper.toResponse(userRepository.save(user));
    }
}
```

## Logging

```java
@Slf4j  // SLF4J logger
public class UserService {
    public void process() {
        log.info("Processing...");
        log.debug("Debug info: {}", data);
        log.error("Error occurred", exception);
    }
}

@Log4j2  // Log4j2 logger
@CommonsLog  // Apache Commons Logging
@JBossLog  // JBoss Logging
```

## DTO Pattern

```java
// Request DTO
@Data
public class CreateUserRequest {
    @NotBlank
    private String name;
    @Email
    private String email;
    @Size(min = 8)
    private String password;
}

// Response DTO (immutable)
@Value
@Builder
public class UserResponse {
    Long id;
    String name;
    String email;
    UserStatus status;
    LocalDateTime createdAt;
}
```

## @Cleanup

```java
public void readFile(String path) throws IOException {
    @Cleanup InputStream in = new FileInputStream(path);
    // in.close() called automatically
}
```

## @SneakyThrows

```java
@SneakyThrows  // Wraps checked exception
public String readConfig() {
    return Files.readString(Path.of("config.json"));
}
```

## @Synchronized

```java
public class Counter {
    @Synchronized
    public void increment() {
        // Thread-safe
    }
}
```

## @With (Immutable Updates)

```java
@Value
@With
public class Point {
    int x;
    int y;
}

Point p1 = new Point(1, 2);
Point p2 = p1.withX(5);  // Point(5, 2)
```

## Key Annotations

| Annotation | Purpose |
|------------|---------|
| `@Data` | Getter, Setter, ToString, Equals, Constructor |
| `@Value` | Immutable class |
| `@Builder` | Builder pattern |
| `@RequiredArgsConstructor` | Constructor for final fields |
| `@Slf4j` | Logger field |
| `@ToString.Exclude` | Exclude from toString |
| `@EqualsAndHashCode.Exclude` | Exclude from equals/hashCode |

---

## When NOT to Use This Skill

| Scenario | Use Instead |
|----------|-------------|
| Java core language | `java` skill |
| MapStruct mapping | `mapstruct` skill |
| Spring annotations | `backend-spring-boot` skill |
| JPA entities complex logic | Manual implementation |
| Public API design | Explicit methods for clarity |

---

## Anti-Patterns

| Anti-Pattern | Why It's Bad | Correct Approach |
|--------------|--------------|------------------|
| @Data on JPA entities | toString/equals issues | Use @Getter/@Setter selectively |
| Not excluding lazy relations | LazyInitializationException | Use @ToString.Exclude |
| @EqualsAndHashCode on entities | Proxy issues | Use @EqualsAndHashCode(onlyExplicitlyIncluded = true) |
| @SneakyThrows everywhere | Hides exceptions | Use proper exception handling |
| @Builder without @Default | Null fields | Add @Builder.Default |
| @Value with mutable fields | Breaks immutability | Use only immutable types |
| Mixing @Data and manual methods | Confusing API | Be consistent |
| Not configuring in lombok.config | Inconsistent behavior | Use lombok.config file |

---

## Quick Troubleshooting

| Issue | Cause | Solution |
|-------|-------|----------|
| "Cannot find symbol" for getters | IDE not processing | Enable annotation processing |
| LazyInitializationException | toString on lazy relation | Add @ToString.Exclude |
| MapStruct not working | Wrong processor order | Lombok before MapStruct |
| Builder missing fields | No @Builder.Default | Add defaults or check config |
| StackOverflowError in equals | Circular reference | Exclude relation fields |
| IDE shows errors but compiles | IDE cache | Invalidate caches/restart |
| @Slf4j logger not found | SLF4J not in classpath | Add SLF4J dependency |
| Generated code not visible | delombok needed | Run delombok task |

---

## Reference Documentation
- [Lombok Documentation](https://projectlombok.org/features/)
- [Stable Features](https://projectlombok.org/features/all)
- [Configuration](https://projectlombok.org/features/configuration)

> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `lombok` for comprehensive documentation.

Wersje

W bazie nie ma innych skilli o nazwie lombok.

Migawka bazy z 13.11.2026 · wersja paczki 8509173db88d (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100mapstruct
    Prowadzi przez framework mapowania MapStruct w Javie: podstawowe mappery, mapowania aktualizujące, obiekty zagnieżdżone, kolekcje, metody własne i integrację z Lombok, w tym mapowanie DTO i konwersję encji.
  • 100mapstruct-patterns
    Podaje dobre praktyki MapStruct: trzy sposoby definiowania mapperów, wstrzykiwanie w Spring, mapowanie zagnieżdżone, @Qualifier zamiast @Named i integrację z Lombok.
  • 100java
    Pomaga pisać aplikacje w Javie 17+ z nowoczesnymi funkcjami: records, sealed classes, strumienie, pattern matching, wyrażenia switch, Optional, kolekcje i generyki, także dla backendów Spring Boot.
  • 100lombok-patterns
    Stosuje poprawne wzorce adnotacji Lombok: @Data, @Builder, @Slf4j, @EqualsAndHashCode(callSuper=true), współpraca z Jackson i @Jacksonized, konflikt z MyBatis, @Value, @With i @SuperBuilder, korygując typowe błędy modeli.
  • 100rust-lombok-macros
    Używa i przegląda derywacje lombok-macros w Rust, które generują gettery, settery, konstruktory i Debug, i pomaga usunąć powtarzalne metody.
  • 100java-dto-converter
    Tworzy DTO i konwertery MapStruct w warstwowych projektach Spring Boot: nazewnictwo, adnotacje walidacji, schematy OpenAPI, serializacja enumów oraz mapowanie aktualizacji i odpowiedzi.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.