-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateGarment.java
More file actions
41 lines (34 loc) · 1.26 KB
/
CreateGarment.java
File metadata and controls
41 lines (34 loc) · 1.26 KB
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
41
package com.outfitlab.project.domain.useCases.garment;
import com.outfitlab.project.domain.interfaces.repositories.GarmentRepository;
import java.util.List;
public class CreateGarment {
private final GarmentRepository garmentRepository;
public CreateGarment(GarmentRepository garmentRepository) {
this.garmentRepository = garmentRepository;
}
public void execute(String name, String type, String color, String brandCode, String imageUrl, String climaNombre, List<String> ocasionesNombres, String genero) {
this.garmentRepository.createGarment(
name,
formatGarmentCode(name),
type,
color,
brandCode,
imageUrl,
climaNombre,
ocasionesNombres,
genero
);
}
private String formatGarmentCode(String input) {
if (input == null) return "";
return input.toLowerCase().trim()
.replace("á", "a")
.replace("é", "e")
.replace("í", "i")
.replace("ó", "o")
.replace("ú", "u")
.replace("ñ", "n")
.replaceAll("[^a-z0-9\\s]", "")
.replaceAll("\\s+", "_");
}
}