Passed
Pull Request — master (#26)
by
unknown
02:25 queued 18s
created

serviceRepresentation(String,String)   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 2
1
package com.hltech.vaunt.generator;
2
3
import com.fasterxml.jackson.databind.JsonMappingException;
4
import com.hltech.vaunt.generator.domain.representation.RepresentationExtractor;
5
import com.hltech.vaunt.generator.domain.representation.RepresentationWriter;
6
import com.hltech.vaunt.generator.domain.representation.model.Service;
7
import lombok.RequiredArgsConstructor;
8
9
import java.io.IOException;
10
11
@RequiredArgsConstructor
12
public class VauntGenerator {
13
14
    private final RepresentationExtractor extractor;
15
    private final RepresentationWriter writer;
16
17
    public void writeVauntFile(String packageRoot, String serviceName, String targetDirectory) {
18
        try {
19
            writer.writeServiceRepresentation(serviceRepresentation(packageRoot, serviceName), targetDirectory);
20
        } catch (IOException ex) {
21
            throw new RuntimeException("Error when trying to write service representation to file", ex);
22
        }
23
    }
24
25
    private Service serviceRepresentation(String packageRoot, String serviceName) {
26
        try {
27
            return extractor.extractServiceRepresentation(packageRoot, serviceName);
28
        } catch (JsonMappingException ex) {
29
            throw new RuntimeException(
30
                    String.format(
31
                            "Error when trying to extract service representation: package=%s, service name=%s",
32
                            packageRoot, serviceName), ex);
33
        }
34
    }
35
}
36