<commit_before>package com.github.blindpirate.gogradle.core.dependency.produce.external.gvtgbvendor;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.blindpirate.gogradle.util.Assert;
import com.github.blindpirate.gogradle.util.StringUtils;
import com.google.common.collect.ImmutableMap;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.github.blindpirate.gogradle.util.StringUtils.*;

/**
 * Model of vendor/manifest in repos managed by gvt or gbvendor.
 *
 * @see <a href="https://github.com/FiloSottile/gvt/blob/master/vendor/manifest">manifest</a>.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class ManifestModel {

    @JsonProperty("generator")
    private String generator;
    @JsonProperty("dependencies")
    private List<DependenciesBean> dependencies;

    public List<Map<String, Object>> toNotations() {
        return dependencies.stream().map(DependenciesBean::toNotation).collect(Collectors.toList());
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class DependenciesBean {
        @JsonProperty("importpath")
        private String importpath;
        @JsonProperty("repository")
        private String repository;
        @JsonProperty("vcs")
        private String vcs;
        @JsonProperty("revision")
        private String revision;
        @JsonProperty("branch")
        private String branch;
        @JsonProperty("path")
        private String path;
        @JsonProperty("notests")
        private boolean notests;

        public Map<String, Object> toNotation() {
            Assert.isNotBlank(importpath);
            return ImmutableMap.of("vcs", vcs,
                    "name", determineName(),
                    "version", revision);
        }

        private String determineName() {
            if (isBlank(path)) {
                return importpath;
            } else {
                Assert.isTrue(importpath.endsWith(path));
                return removeEnd(importpath, path);
            }
        }
    }
}<commit_msg>prevent null values in map<commit_after>package com.github.blindpirate.gogradle.core.dependency.produce.external.gvtgbvendor;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.blindpirate.gogradle.util.Assert;
import com.github.blindpirate.gogradle.util.MapUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.github.blindpirate.gogradle.util.StringUtils.isBlank;
import static com.github.blindpirate.gogradle.util.StringUtils.removeEnd;

/**
 * Model of vendor/manifest in repos managed by gvt or gbvendor.
 *
 * @see <a href="https://github.com/FiloSottile/gvt/blob/master/vendor/manifest">manifest</a>.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class ManifestModel {

    @JsonProperty("generator")
    private String generator;
    @JsonProperty("dependencies")
    private List<DependenciesBean> dependencies;

    public List<Map<String, Object>> toNotations() {
        return dependencies.stream().map(DependenciesBean::toNotation).collect(Collectors.toList());
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class DependenciesBean {
        @JsonProperty("importpath")
        private String importpath;
        @JsonProperty("repository")
        private String repository;
        @JsonProperty("vcs")
        private String vcs;
        @JsonProperty("revision")
        private String revision;
        @JsonProperty("branch")
        private String branch;
        @JsonProperty("path")
        private String path;
        @JsonProperty("notests")
        private boolean notests;

        public Map<String, Object> toNotation() {
            Assert.isNotBlank(importpath);
            return MapUtils.asMapWithoutNull("vcs", vcs,
                    "name", determineName(),
                    "version", revision);
        }

        private String determineName() {
            if (isBlank(path)) {
                return importpath;
            } else {
                Assert.isTrue(importpath.endsWith(path));
                return removeEnd(importpath, path);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10724043715846994, 'fraction_numerical': 0.0, 'mean_word_length': 2.957657657657658, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7493573', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1181, 'n_words': 231}