44import com .fasterxml .jackson .databind .ObjectMapper ;
55import com .fasterxml .jackson .dataformat .yaml .YAMLFactory ;
66import com .flowci .common .validator .ValidName ;
7- import com .flowci .yaml .business .ParseYamlV2 ;
7+ import com .flowci .yaml .business .ParseYaml ;
88import com .flowci .yaml .exception .InvalidYamlException ;
9- import com .flowci .yaml .model .FlowV2 ;
10- import com .flowci .yaml .model .StepV2 ;
9+ import com .flowci .yaml .model .v2 . FlowV2 ;
10+ import com .flowci .yaml .model .v2 . StepV2 ;
1111import lombok .extern .slf4j .Slf4j ;
1212import org .springframework .stereotype .Component ;
13- import org .springframework .util .CollectionUtils ;
1413
15- import java .util .*;
14+ import java .util .HashMap ;
15+ import java .util .HashSet ;
16+ import java .util .List ;
1617
1718import static java .lang .String .format ;
1819import static org .springframework .util .CollectionUtils .isEmpty ;
1920import static org .springframework .util .StringUtils .hasText ;
2021
2122@ Slf4j
2223@ Component
23- public class ParseYamlV2Impl implements ParseYamlV2 {
24+ public class ParseYamlV2Impl implements ParseYaml {
2425
2526 private static final ObjectMapper objectMapper = new ObjectMapper (new YAMLFactory ());
2627 private static final ValidName .NameValidator nameValidator = new ValidName .NameValidator ();
@@ -48,7 +49,7 @@ public FlowV2 invoke(String yaml) {
4849
4950 private void validateSteps (FlowV2 flow ) {
5051 var steps = flow .getSteps ();
51- if (CollectionUtils . isEmpty (steps )) {
52+ if (isEmpty (steps )) {
5253 throw new InvalidYamlException ("at least one step is required" );
5354 }
5455
@@ -78,7 +79,7 @@ private void validateSteps(FlowV2 flow) {
7879
7980 private void validateCommands (StepV2 step ) {
8081 var commands = step .getCommands ();
81- if (CollectionUtils . isEmpty (commands )) {
82+ if (isEmpty (commands )) {
8283 throw new InvalidYamlException (format ("at least one command under step '%s' is required" , step .getName ()));
8384 }
8485
@@ -101,7 +102,7 @@ private void buildGraph(FlowV2 flow) {
101102 }
102103
103104 for (var step : steps ) {
104- if (CollectionUtils . isEmpty (step .getDependsOn ())) {
105+ if (isEmpty (step .getDependsOn ())) {
105106 continue ;
106107 }
107108
@@ -137,13 +138,4 @@ private void checkCircularDependencies(List<StepV2> steps, HashMap<StepV2, Integ
137138 checkCircularDependencies (step .getNext (), traversed );
138139 }
139140 }
140-
141- /**
142- * Ex:
143- * A <-- B <-- C
144- * A <-- C
145- */
146- private void checkDuplicatedDependsOn (List <StepV2 > steps ) {
147-
148- }
149141}
0 commit comments