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

com.ning.api.client.json.ResponseWithResources Maven / Gradle / Ivy

There is a newer version: 0.5.1
Show newest version
package com.ning.api.client.json;

import java.io.IOException;
import java.util.LinkedHashMap;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.ObjectMapper;

import com.ning.api.client.item.ContentItem;

/**
 * Intermediate response type class for responses that can contain
 * associated "sub-resources". This currently contains all response types
 * except simple count query responses.
 */
public class ResponseWithResources extends XapiResponse
{
    @JsonProperty
    private LinkedHashMap resources;

    public ResponseWithResources() { }

    /* TODO: should this be exposed?
    public LinkedHashMap getResources()
    {
        return resources;
    }
*/

    public > T getResource(String key, Class type,
            ObjectMapper mapper)
        throws IOException
    {
        if (resources != null) {
            JsonNode node = resources.get(key);
            if (node != null) {
                return mapper.readValue(node.traverse(), type);
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy