|
| 1 | +package org.openstack4j.openstack.image.v2.domain; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 4 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 5 | +import com.google.common.base.Objects; |
| 6 | +import org.openstack4j.model.image.v2.CachedImage; |
| 7 | +import org.openstack4j.openstack.common.CustomEpochToDateDeserializer; |
| 8 | +import org.openstack4j.openstack.common.ListResult; |
| 9 | + |
| 10 | +import java.util.Date; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +/** |
| 14 | + * @author zdagjyo on 13/11/2018. |
| 15 | + */ |
| 16 | +public class CachedGlanceImage implements CachedImage { |
| 17 | + |
| 18 | + private static final long serialVersionUID = 1L; |
| 19 | + |
| 20 | + @JsonProperty("image_id") |
| 21 | + private String imageId; |
| 22 | + |
| 23 | + private Integer hits; |
| 24 | + |
| 25 | + @JsonProperty("last_accessed") |
| 26 | + @JsonDeserialize(using = CustomEpochToDateDeserializer.class) |
| 27 | + private Date lastAccessed; |
| 28 | + |
| 29 | + @JsonDeserialize(using = CustomEpochToDateDeserializer.class) |
| 30 | + @JsonProperty("last_modified") |
| 31 | + private Date lastModified; |
| 32 | + |
| 33 | + private Long size; |
| 34 | + |
| 35 | + @Override |
| 36 | + public String getImageId() { |
| 37 | + return imageId; |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public Date getLastAccessed() { |
| 42 | + return lastAccessed; |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public Date getLastModified() { |
| 47 | + return lastModified; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public Integer getHits() { |
| 52 | + return hits; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public Long getSize() { |
| 57 | + return size; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * {@inheritDoc} |
| 62 | + */ |
| 63 | + @Override |
| 64 | + public String toString() { |
| 65 | + return Objects.toStringHelper(this).omitNullValues() |
| 66 | + .add("id", imageId).add("size", size).add("hits", hits).add("lastAccessed", lastAccessed) |
| 67 | + .add("lastModified", lastModified).addValue("\n") |
| 68 | + .toString(); |
| 69 | + } |
| 70 | + |
| 71 | + public static class CachedImages extends ListResult<CachedGlanceImage> { |
| 72 | + |
| 73 | + private static final long serialVersionUID = 1L; |
| 74 | + @JsonProperty("cached_images") |
| 75 | + private List<CachedGlanceImage> cachedImages; |
| 76 | + |
| 77 | + @Override |
| 78 | + protected List<CachedGlanceImage> value() { |
| 79 | + return cachedImages; |
| 80 | + } |
| 81 | + } |
| 82 | +} |
0 commit comments