| 1 | /** |
| 2 | * |
| 3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
| 4 | * |
| 5 | * ==================================================================== |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * ==================================================================== |
| 18 | */ |
| 19 | package org.jclouds.cloudservers.domain; |
| 20 | |
| 21 | import java.util.Date; |
| 22 | |
| 23 | /** |
| 24 | * An image is a collection of files used to create or rebuild a server. Rackspace provides a number |
| 25 | * of pre-built OS images by default. You may also create custom images from cloud servers you have |
| 26 | * launched. These custom images are useful for backup purposes or for producing gold server images |
| 27 | * if you plan to deploy a particular server configuration frequently. |
| 28 | * |
| 29 | * @author Adrian Cole |
| 30 | */ |
| 31 | public class Image { |
| 32 | |
| 33 | private Date created; |
| 34 | private int id; |
| 35 | private String name; |
| 36 | private Integer progress; |
| 37 | private Integer serverId; |
| 38 | private ImageStatus status; |
| 39 | private Date updated; |
| 40 | |
| 41 | public Image() { |
| 42 | } |
| 43 | |
| 44 | public Image(int id, String name) { |
| 45 | this.id = id; |
| 46 | this.name = name; |
| 47 | } |
| 48 | |
| 49 | public void setCreated(Date created) { |
| 50 | this.created = created; |
| 51 | } |
| 52 | |
| 53 | public Date getCreated() { |
| 54 | return created; |
| 55 | } |
| 56 | |
| 57 | public void setId(int id) { |
| 58 | this.id = id; |
| 59 | } |
| 60 | |
| 61 | public int getId() { |
| 62 | return id; |
| 63 | } |
| 64 | |
| 65 | public void setName(String name) { |
| 66 | this.name = name; |
| 67 | } |
| 68 | |
| 69 | public String getName() { |
| 70 | return name; |
| 71 | } |
| 72 | |
| 73 | public void setProgress(Integer progress) { |
| 74 | this.progress = progress; |
| 75 | } |
| 76 | |
| 77 | public Integer getProgress() { |
| 78 | return progress; |
| 79 | } |
| 80 | |
| 81 | public void setServerId(Integer serverId) { |
| 82 | this.serverId = serverId; |
| 83 | } |
| 84 | |
| 85 | public Integer getServerId() { |
| 86 | return serverId; |
| 87 | } |
| 88 | |
| 89 | public void setStatus(ImageStatus status) { |
| 90 | this.status = status; |
| 91 | } |
| 92 | |
| 93 | public ImageStatus getStatus() { |
| 94 | return status; |
| 95 | } |
| 96 | |
| 97 | public void setUpdated(Date updated) { |
| 98 | this.updated = updated; |
| 99 | } |
| 100 | |
| 101 | public Date getUpdated() { |
| 102 | return updated; |
| 103 | } |
| 104 | /** |
| 105 | * note that this ignores the create time |
| 106 | */ |
| 107 | @Override |
| 108 | public int hashCode() { |
| 109 | final int prime = 31; |
| 110 | int result = 1; |
| 111 | result = prime * result + id; |
| 112 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 113 | result = prime * result + ((serverId == null) ? 0 : serverId.hashCode()); |
| 114 | return result; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * note that this ignores the serverid and create time. |
| 119 | */ |
| 120 | @Override |
| 121 | public boolean equals(Object obj) { |
| 122 | if (this == obj) |
| 123 | return true; |
| 124 | if (obj == null) |
| 125 | return false; |
| 126 | if (getClass() != obj.getClass()) |
| 127 | return false; |
| 128 | Image other = (Image) obj; |
| 129 | if (id != other.id) |
| 130 | return false; |
| 131 | if (name == null) { |
| 132 | if (other.name != null) |
| 133 | return false; |
| 134 | } else if (!name.equals(other.name)) |
| 135 | return false; |
| 136 | return true; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public String toString() { |
| 141 | return "Image [created=" + created + ", id=" + id + ", name=" + name + ", serverId=" |
| 142 | + serverId + "]"; |
| 143 | } |
| 144 | |
| 145 | } |