| 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 | /** |
| 22 | * |
| 23 | * A flavor is an available hardware configuration for a server. Each flavor has a unique |
| 24 | * combination of disk space and memory capacity. |
| 25 | * |
| 26 | * @author Adrian Cole |
| 27 | */ |
| 28 | public class Flavor { |
| 29 | |
| 30 | public Flavor() { |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public String toString() { |
| 35 | return "Flavor [disk=" + disk + ", id=" + id + ", name=" + name + ", ram=" + ram + "]"; |
| 36 | } |
| 37 | |
| 38 | public Flavor(int id, String name) { |
| 39 | this.id = id; |
| 40 | this.name = name; |
| 41 | } |
| 42 | |
| 43 | private int id; |
| 44 | private String name; |
| 45 | private Integer disk; |
| 46 | private Integer ram; |
| 47 | |
| 48 | public Integer getDisk() { |
| 49 | return disk; |
| 50 | } |
| 51 | |
| 52 | public void setDisk(Integer value) { |
| 53 | this.disk = value; |
| 54 | } |
| 55 | |
| 56 | public int getId() { |
| 57 | return id; |
| 58 | } |
| 59 | |
| 60 | public void setId(int value) { |
| 61 | this.id = value; |
| 62 | } |
| 63 | |
| 64 | public String getName() { |
| 65 | return name; |
| 66 | } |
| 67 | |
| 68 | public void setName(String value) { |
| 69 | this.name = value; |
| 70 | } |
| 71 | |
| 72 | public Integer getRam() { |
| 73 | return ram; |
| 74 | } |
| 75 | |
| 76 | public void setRam(Integer value) { |
| 77 | this.ram = value; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public int hashCode() { |
| 82 | final int prime = 31; |
| 83 | int result = 1; |
| 84 | result = prime * result + ((disk == null) ? 0 : disk.hashCode()); |
| 85 | result = prime * result + id; |
| 86 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 87 | result = prime * result + ((ram == null) ? 0 : ram.hashCode()); |
| 88 | return result; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public boolean equals(Object obj) { |
| 93 | if (this == obj) |
| 94 | return true; |
| 95 | if (obj == null) |
| 96 | return false; |
| 97 | if (getClass() != obj.getClass()) |
| 98 | return false; |
| 99 | Flavor other = (Flavor) obj; |
| 100 | if (disk == null) { |
| 101 | if (other.disk != null) |
| 102 | return false; |
| 103 | } else if (!disk.equals(other.disk)) |
| 104 | return false; |
| 105 | if (id != other.id) |
| 106 | return false; |
| 107 | if (name == null) { |
| 108 | if (other.name != null) |
| 109 | return false; |
| 110 | } else if (!name.equals(other.name)) |
| 111 | return false; |
| 112 | if (ram == null) { |
| 113 | if (other.ram != null) |
| 114 | return false; |
| 115 | } else if (!ram.equals(other.ram)) |
| 116 | return false; |
| 117 | return true; |
| 118 | } |
| 119 | |
| 120 | } |