-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecipeEntity.java
40 lines (34 loc) · 979 Bytes
/
RecipeEntity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.example.cleaner_int_tests.data;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.List;
import static java.util.Arrays.asList;
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RecipeEntity {
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String id;
private String name;
private String instructions;
private String ingredients;
@Transient
public List<String> getIngredientsList() {
return asList(ingredients.split(","));
}
@Transient
public void setIngredientsList(List<String> ingredients) {
this.ingredients = String.join(",", ingredients);
}
}