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

com.files.util.ModelUtils Maven / Gradle / Ivy

Go to download

The Files.com Java client library provides convenient access to the Files.com API from JVM based applications.

There is a newer version: 1.4.123
Show newest version
package com.files.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import java.util.HashMap;

public class ModelUtils {
  private ModelUtils() {
  }

  public static HashMap toParameterMap(String object) {
    ObjectMapper mapper = JsonMapper
        .builder()
        .disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)
        .build();

    TypeReference> typeRef = new TypeReference>() {};
    HashMap parameters;
    try {
      parameters = mapper.readValue(object, typeRef);
    } catch (JsonProcessingException e) {
      parameters = null;
    }
    return parameters;
  }

  public static String forceMandatoryUriEncode(String uri) {
    return uri.replaceAll(";", "%3B");
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy