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

org.molgenis.navigator.util.ResourceIdentifierUtil Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.navigator.util;

import static com.google.common.collect.Lists.newArrayList;

import com.google.gson.Gson;
import java.util.List;
import java.util.Map;
import org.molgenis.navigator.model.ResourceIdentifier;
import org.molgenis.navigator.model.ResourceType;

public class ResourceIdentifierUtil {

  private ResourceIdentifierUtil() {}

  public static List getResourcesFromJson(String resourceJson) {
    Gson gson = new Gson();
    List resources = newArrayList();

    @SuppressWarnings("unchecked")
    List> jsonList = gson.fromJson(resourceJson, List.class);
    for (Map jsonResource : jsonList) {
      resources.add(
          ResourceIdentifier.create(
              ResourceType.valueOf(jsonResource.get("type")), jsonResource.get("id")));
    }
    return resources;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy