Search in sources :

Example 1 with Directories

use of org.commonjava.indy.pkg.npm.model.Directories in project indy by Commonjava.

the class VersionMetadataDeserializer method deserialize.

@Override
public VersionMetadata deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    final ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
    final JsonNode vNode = mapper.readTree(jsonParser);
    VersionMetadata vm = new VersionMetadata(parseValue(vNode, "name"), parseValue(vNode, "version"));
    vm.setDescription(parseValue(vNode, "description"));
    JsonNode repoNode = vNode.get("repository");
    if (repoNode instanceof ArrayNode) {
        repoNode = repoNode.get(0);
    }
    vm.setRepository(new Repository(parseValue(repoNode, "type"), parseValue(repoNode, "url")));
    vm.setAuthor(parseObject(mapper, vNode.get("author"), UserInfo.class));
    vm.setBugs(parseObject(mapper, vNode.get("bugs"), Bugs.class));
    vm.setDist(parseObject(mapper, vNode.get("dist"), Dist.class));
    vm.setDirectories(parseObject(mapper, vNode.get("directories"), Directories.class));
    vm.setKeywords(parseList(mapper, vNode.get("keywords"), String.class));
    vm.setLicense(parseObject(mapper, vNode.get("license"), License.class));
    vm.setMain(parseValue(vNode, "main"));
    vm.setUrl(parseValue(vNode, "url"));
    vm.setContributors(parseList(mapper, vNode.get("contributors"), UserInfo.class));
    vm.setEngines(parseList(mapper, vNode.get("engines"), Engines.class));
    vm.setDependencies(parseObject(mapper, vNode.get("dependencies"), Map.class));
    vm.setDevDependencies(parseObject(mapper, vNode.get("devDependencies"), Map.class));
    vm.setMaintainers(parseList(mapper, vNode.get("maintainers"), UserInfo.class));
    vm.setLicenses(parseList(mapper, vNode.get("licenses"), License.class));
    vm.setScripts(parseObject(mapper, vNode.get("scripts"), Map.class));
    return vm;
}
Also used : Bugs(org.commonjava.indy.pkg.npm.model.Bugs) Dist(org.commonjava.indy.pkg.npm.model.Dist) License(org.commonjava.indy.pkg.npm.model.License) JsonNode(com.fasterxml.jackson.databind.JsonNode) UserInfo(org.commonjava.indy.pkg.npm.model.UserInfo) Engines(org.commonjava.indy.pkg.npm.model.Engines) Directories(org.commonjava.indy.pkg.npm.model.Directories) Repository(org.commonjava.indy.pkg.npm.model.Repository) VersionMetadata(org.commonjava.indy.pkg.npm.model.VersionMetadata) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Map (java.util.Map)1 Bugs (org.commonjava.indy.pkg.npm.model.Bugs)1 Directories (org.commonjava.indy.pkg.npm.model.Directories)1 Dist (org.commonjava.indy.pkg.npm.model.Dist)1 Engines (org.commonjava.indy.pkg.npm.model.Engines)1 License (org.commonjava.indy.pkg.npm.model.License)1 Repository (org.commonjava.indy.pkg.npm.model.Repository)1 UserInfo (org.commonjava.indy.pkg.npm.model.UserInfo)1 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)1