michael-nmg/java-project-71

View on GitHub
app/src/main/java/hexlet/code/parsers/ParserYaml.java

Summary

Maintainability
A
0 mins
Test Coverage
package hexlet.code.parsers;

import java.util.Map;
import java.util.HashMap;
import java.io.IOException;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;

public final class ParserYaml implements Parser {

    public Map<String, Object> parse(byte[] data) throws IOException {
        if (data.length == 0) {
            return new HashMap<>();
        }

        return new YAMLMapper().readValue(data, new TypeReference<>() {
        });
    }

}