| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.trmk.vcloud_0_8.domain; |
| 20 | |
| 21 | /** |
| 22 | * reports storage resource consumption in a vDC. |
| 23 | * |
| 24 | * @author Adrian Cole |
| 25 | */ |
| 26 | public class Capacity { |
| 27 | |
| 28 | private final String units; |
| 29 | private final long allocated; |
| 30 | private final long limit; |
| 31 | private final int used; |
| 32 | private final long overhead; |
| 33 | |
| 34 | public Capacity(String units, long allocated, long limit, int used, long overhead) { |
| 35 | this.units = units; |
| 36 | this.limit = limit; |
| 37 | this.allocated = allocated; |
| 38 | this.used = used; |
| 39 | this.overhead = overhead; |
| 40 | } |
| 41 | |
| 42 | public String getUnits() { |
| 43 | return units; |
| 44 | } |
| 45 | |
| 46 | public long getAllocated() { |
| 47 | return allocated; |
| 48 | } |
| 49 | |
| 50 | public long getLimit() { |
| 51 | return limit; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * percentage of the allocation in use. |
| 56 | */ |
| 57 | public int getUsed() { |
| 58 | return used; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * number of Units allocated to vShield Manager virtual machines provisioned from this vDC. |
| 63 | */ |
| 64 | public long getOverhead() { |
| 65 | return overhead; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public int hashCode() { |
| 70 | final int prime = 31; |
| 71 | int result = 1; |
| 72 | result = prime * result + (int) (allocated ^ (allocated >>> 32)); |
| 73 | result = prime * result + (int) (limit ^ (limit >>> 32)); |
| 74 | result = prime * result + (int) (overhead ^ (overhead >>> 32)); |
| 75 | result = prime * result + ((units == null) ? 0 : units.hashCode()); |
| 76 | result = prime * result + used; |
| 77 | return result; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public boolean equals(Object obj) { |
| 82 | if (this == obj) |
| 83 | return true; |
| 84 | if (obj == null) |
| 85 | return false; |
| 86 | if (getClass() != obj.getClass()) |
| 87 | return false; |
| 88 | Capacity other = (Capacity) obj; |
| 89 | if (allocated != other.allocated) |
| 90 | return false; |
| 91 | if (limit != other.limit) |
| 92 | return false; |
| 93 | if (overhead != other.overhead) |
| 94 | return false; |
| 95 | if (units == null) { |
| 96 | if (other.units != null) |
| 97 | return false; |
| 98 | } else if (!units.equals(other.units)) |
| 99 | return false; |
| 100 | if (used != other.used) |
| 101 | return false; |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public String toString() { |
| 107 | return "[allocated=" + allocated + ", limit=" + limit + ", overhead=" + overhead + ", units=" + units + ", used=" |
| 108 | + used + "]"; |
| 109 | } |
| 110 | } |