javaandroidrobospicegoogle-http-client

Robospice Cached Object is Always null


For some reason pulling a cached object back from the cache in Robospice is always null. Is there something I'm doing wrong?

getSpiceManager().execute(cardRequest, Card.class.getName(),  
                           DurationInMillis.ONE_DAY, new CardRequestListener());

Is how it's executed. The spice manager is created as follows:

mSpiceManager = new SpiceManager(JacksonGoogleHttpClientSpiceService.class);

And the card class is as follows:

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "iosThumbHighRes",
    "iosThumb",
    "iosLargeHiRes",
    "iosLargeHighRes",
    "iosLarge"
})
public class Card {

    @JsonProperty("iosThumbHighRes")
    private String iosThumbHighRes;
    @JsonProperty("iosThumb")
    private String iosThumb;
    @JsonProperty("iosLargeHiRes")
    private String iosLargeHiRes;
    @JsonProperty("iosLargeHighRes")
    private String iosLargeHighRes;
    @JsonProperty("iosLarge")
    private String iosLarge;
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    @JsonProperty("iosThumbHighRes")
    public String getIosThumbHighRes() {
        return iosThumbHighRes;
    }

    @JsonProperty("iosThumbHighRes")
    public void setIosThumbHighRes(String iosThumbHighRes) {
        this.iosThumbHighRes = iosThumbHighRes;
    }

    @JsonProperty("iosThumb")
    public String getIosThumb() {
        return iosThumb;
    }

    @JsonProperty("iosThumb")
    public void setIosThumb(String iosThumb) {
        this.iosThumb = iosThumb;
    }

    @JsonProperty("iosLargeHiRes")
    public String getIosLargeHiRes() {
        return iosLargeHiRes;
    }

    @JsonProperty("iosLargeHiRes")
    public void setIosLargeHiRes(String iosLargeHiRes) {
        this.iosLargeHiRes = iosLargeHiRes;
    }

    @JsonProperty("iosLargeHighRes")
    public String getIosLargeHighRes() {
        return iosLargeHighRes;
    }

    @JsonProperty("iosLargeHighRes")
    public void setIosLargeHighRes(String iosLargeHighRes) {
        this.iosLargeHighRes = iosLargeHighRes;
    }

    @JsonProperty("iosLarge")
    public String getIosLarge() {
        return iosLarge;
    }

    @JsonProperty("iosLarge")
    public void setIosLarge(String iosLarge) {
        this.iosLarge = iosLarge;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object other) {
        return EqualsBuilder.reflectionEquals(this, other);
    }

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperties(String name, Object value) {
        this.additionalProperties.put(name, value);
    }

}

Is there something else I need to set?

Thanks, Graeme


Solution

  • The Google Http Client uses the @Key annotation. You are using Jackson annotation which is not supported by Googe Http Java Client, as it provides an abstraction layer over all serialisation solutions (gson/jackson).