Skip to content

Commit 71f37d8

Browse files
author
Jörg-Christian Müller
committed
Project Lombok Builder Pattern
1 parent b6a85d3 commit 71f37d8

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/main/java/guru/springframework/spring6restmvc/model/Beer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package guru.springframework.spring6restmvc.model;
22

3+
import lombok.Builder;
34
import lombok.Data;
45

56
import java.math.BigDecimal;
@@ -9,6 +10,7 @@
910
/**
1011
* Created by jt, Spring Framework Guru.
1112
*/
13+
@Builder
1214
@Data
1315
public class Beer {
1416
private UUID id;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package guru.springframework.spring6restmvc.services;
2+
3+
import guru.springframework.spring6restmvc.model.Beer;
4+
5+
import java.util.UUID;
6+
7+
/**
8+
* Created by jt, Spring Framework Guru.
9+
*/
10+
public interface BeerService {
11+
12+
Beer getBeerById(UUID id);
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package guru.springframework.spring6restmvc.services;
2+
3+
import guru.springframework.spring6restmvc.model.Beer;
4+
import guru.springframework.spring6restmvc.model.BeerStyle;
5+
6+
import java.math.BigDecimal;
7+
import java.time.LocalDateTime;
8+
import java.util.UUID;
9+
10+
/**
11+
* Created by jt, Spring Framework Guru.
12+
*/
13+
public class BeerServiceImpl implements BeerService {
14+
@Override
15+
public Beer getBeerById(UUID id) {
16+
return Beer.builder()
17+
.id(id)
18+
.version(1)
19+
.beerName("Galaxy Cat")
20+
.beerStyle(BeerStyle.PALE_ALE)
21+
.upc("12356")
22+
.price(new BigDecimal("12.99"))
23+
.quantityOnHand(122)
24+
.createdDate(LocalDateTime.now())
25+
.updateDate(LocalDateTime.now())
26+
.build();
27+
}
28+
}

0 commit comments

Comments
 (0)