| 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.deltacloud.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import java.net.URI; |
| 24 | import java.util.Set; |
| 25 | |
| 26 | import com.google.common.collect.ImmutableSet; |
| 27 | |
| 28 | /** |
| 29 | * A hardware profile represents a configuration of resources upon which a machine may be deployed. |
| 30 | * It defines aspects such as local disk storage, available RAM, and architecture. Each provider is |
| 31 | * free to define as many (or as few) hardware profiles as desired. |
| 32 | * |
| 33 | * @author Adrian Cole |
| 34 | */ |
| 35 | public class HardwareProfile { |
| 36 | private final URI href; |
| 37 | private final String id; |
| 38 | private final String name; |
| 39 | private final Set<? extends HardwareProperty> properties; |
| 40 | |
| 41 | public HardwareProfile(URI href, String id, String name, Set<? extends HardwareProperty> properties) { |
| 42 | this.href = checkNotNull(href, "href"); |
| 43 | this.id = checkNotNull(id, "id"); |
| 44 | this.name = checkNotNull(name, "name"); |
| 45 | this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties")); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * |
| 50 | * @return URL to manipulate a specific profile |
| 51 | */ |
| 52 | public URI getHref() { |
| 53 | return href; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * |
| 58 | * @return A unique identifier for the profile |
| 59 | */ |
| 60 | public String getId() { |
| 61 | return id; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * |
| 66 | * @return A short label |
| 67 | */ |
| 68 | public String getName() { |
| 69 | return name; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * |
| 74 | * @return properties included in this hardware profile |
| 75 | */ |
| 76 | public Set<? extends HardwareProperty> getProperties() { |
| 77 | return properties; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public int hashCode() { |
| 82 | final int prime = 31; |
| 83 | int result = 1; |
| 84 | result = prime * result + ((href == null) ? 0 : href.hashCode()); |
| 85 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
| 86 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 87 | result = prime * result + ((properties == null) ? 0 : properties.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 | HardwareProfile other = (HardwareProfile) obj; |
| 100 | if (href == null) { |
| 101 | if (other.href != null) |
| 102 | return false; |
| 103 | } else if (!href.equals(other.href)) |
| 104 | return false; |
| 105 | if (id == null) { |
| 106 | if (other.id != null) |
| 107 | return false; |
| 108 | } else if (!id.equals(other.id)) |
| 109 | return false; |
| 110 | if (name == null) { |
| 111 | if (other.name != null) |
| 112 | return false; |
| 113 | } else if (!name.equals(other.name)) |
| 114 | return false; |
| 115 | if (properties == null) { |
| 116 | if (other.properties != null) |
| 117 | return false; |
| 118 | } else if (!properties.equals(other.properties)) |
| 119 | return false; |
| 120 | return true; |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public String toString() { |
| 125 | return "[href=" + href + ", id=" + id + ", name=" + name + ", properties=" + properties + "]"; |
| 126 | } |
| 127 | |
| 128 | } |