All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.giraone.io.copier.web.index.AutoIndexReader Maven / Gradle / Ivy

Go to download

Utility JAR for copying a file tree from web server or from classpath resources to a (local) file system.

The newest version!
package com.giraone.io.copier.web.index;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class AutoIndexReader {

    private static final TypeReference> listAutoIndexItemTypeRef
        = new TypeReference<>() {
    };
    private static final ObjectMapper objectMapper = buildObjectMapper();

    public AutoIndexReader() {
    }

    public List read(InputStream in) throws IOException {
        return objectMapper.readValue(in, listAutoIndexItemTypeRef);
    }

    private static ObjectMapper buildObjectMapper() {

        final ObjectMapper mapper = new ObjectMapper();
        // Be tolerant in reading
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        // Date/Date-Time settings
        mapper.registerModule(new JavaTimeModule());
        return mapper;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy