Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 lombok builders #22

Open
wants to merge 3 commits into
base: 2-lombok-builders
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>guru.springframework</groupId>
Expand All @@ -14,7 +14,7 @@
<name>spring-6-rest-mvc</name>
<description>spring-6-rest-mvc</description>
<properties>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/guru/springframework/spring6restmvc/model/Beer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package guru.springframework.spring6restmvc.model;

import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;

/**
* Created by jt, Spring Framework Guru.
*/
@Builder
@Data
public class Beer {
private UUID id;
private Integer version;
private String beerName;
private BeerStyle beerStyle;
private String upc;
private Integer quantityOnHand;
private BigDecimal price;
private LocalDateTime createdDate;
private LocalDateTime updateDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package guru.springframework.spring6restmvc.model;

/**
* Created by jt, Spring Framework Guru.
*/
public enum BeerStyle {
LAGER, PILSNER, STOUT, GOSE, PORTER, ALE, WHEAT, IPA, PALE_ALE, SAISON
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package guru.springframework.spring6restmvc.services;

import guru.springframework.spring6restmvc.model.Beer;

import java.util.UUID;

/**
* Created by jt, Spring Framework Guru.
*/
public interface BeerService {

Beer getBeerById(UUID id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package guru.springframework.spring6restmvc.services;

import guru.springframework.spring6restmvc.model.Beer;
import guru.springframework.spring6restmvc.model.BeerStyle;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;

/**
* Created by jt, Spring Framework Guru.
*/
public class BeerServiceImpl implements BeerService {
@Override
public Beer getBeerById(UUID id) {
return Beer.builder()
.id(id)
.version(1)
.beerName("Galaxy Cat")
.beerStyle(BeerStyle.PALE_ALE)
.upc("12356")
.price(new BigDecimal("12.99"))
.quantityOnHand(122)
.createdDate(LocalDateTime.now())
.updateDate(LocalDateTime.now())
.build();
}
}