Search in sources :

Example 1 with CollectionLikeType

use of com.fasterxml.jackson.databind.type.CollectionLikeType in project assembly64fx by freabemania.

the class ArtifactsService method getLatestVersion.

public String getLatestVersion(File db) {
    try {
        ObjectMapper mapper = getObjectMapper();
        CollectionLikeType constructCollectionLikeType = mapper.getTypeFactory().constructCollectionLikeType(List.class, String.class);
        List<String> versions = mapper.readValue(FileUtils.readFileToString(db), constructCollectionLikeType);
        return versions.get(0);
    } catch (Exception e) {
        return null;
    }
}
Also used : CollectionLikeType(com.fasterxml.jackson.databind.type.CollectionLikeType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Support.getObjectMapper(se.light.assembly64.Support.getObjectMapper) IOException(java.io.IOException)

Example 2 with CollectionLikeType

use of com.fasterxml.jackson.databind.type.CollectionLikeType in project assembly64fx by freabemania.

the class LocalDBService method getWorkLocations.

public List<WorkLocation> getWorkLocations(boolean forceUpdate) throws RuntimeException {
    if (workLocations != null && !forceUpdate) {
        return workLocations;
    }
    try {
        File file = pathService.getWorkLocationsFile();
        // bootstrap file
        if (!file.exists()) {
            storeWorkLocations(new ArrayList<>());
        }
        CollectionLikeType constructCollectionType = getObjectMapper().getTypeFactory().constructCollectionLikeType(ArrayList.class, WorkLocation.class);
        this.workLocations = getObjectMapper().readValue(FileUtils.readFileToString(file), constructCollectionType);
        return workLocations;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CollectionLikeType(com.fasterxml.jackson.databind.type.CollectionLikeType) LocalStorageUtil.getSubdirOrFile(se.light.assembly64.util.LocalStorageUtil.getSubdirOrFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

CollectionLikeType (com.fasterxml.jackson.databind.type.CollectionLikeType)2 IOException (java.io.IOException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 Support.getObjectMapper (se.light.assembly64.Support.getObjectMapper)1 LocalStorageUtil.getSubdirOrFile (se.light.assembly64.util.LocalStorageUtil.getSubdirOrFile)1