| 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 | |
| 25 | /** |
| 26 | * A parameter corresponding to a hardware option. |
| 27 | * |
| 28 | * @author Adrian Cole |
| 29 | */ |
| 30 | public class HardwareParameter { |
| 31 | @Override |
| 32 | public int hashCode() { |
| 33 | final int prime = 31; |
| 34 | int result = 1; |
| 35 | result = prime * result + ((href == null) ? 0 : href.hashCode()); |
| 36 | result = prime * result + ((method == null) ? 0 : method.hashCode()); |
| 37 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 38 | result = prime * result + ((operation == null) ? 0 : operation.hashCode()); |
| 39 | return result; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public boolean equals(Object obj) { |
| 44 | if (this == obj) |
| 45 | return true; |
| 46 | if (obj == null) |
| 47 | return false; |
| 48 | if (getClass() != obj.getClass()) |
| 49 | return false; |
| 50 | HardwareParameter other = (HardwareParameter) obj; |
| 51 | if (href == null) { |
| 52 | if (other.href != null) |
| 53 | return false; |
| 54 | } else if (!href.equals(other.href)) |
| 55 | return false; |
| 56 | if (method == null) { |
| 57 | if (other.method != null) |
| 58 | return false; |
| 59 | } else if (!method.equals(other.method)) |
| 60 | return false; |
| 61 | if (name == null) { |
| 62 | if (other.name != null) |
| 63 | return false; |
| 64 | } else if (!name.equals(other.name)) |
| 65 | return false; |
| 66 | if (operation == null) { |
| 67 | if (other.operation != null) |
| 68 | return false; |
| 69 | } else if (!operation.equals(other.operation)) |
| 70 | return false; |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | private final URI href; |
| 75 | private final String method; |
| 76 | private final String name; |
| 77 | private final String operation; |
| 78 | |
| 79 | public HardwareParameter(URI href, String method, String name, String operation) { |
| 80 | this.href = checkNotNull(href, "href"); |
| 81 | this.method = checkNotNull(method, "method"); |
| 82 | this.name = checkNotNull(name, "name"); |
| 83 | this.operation = checkNotNull(operation, "operation"); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * |
| 88 | * @return URI of the action this applies to |
| 89 | */ |
| 90 | public URI getHref() { |
| 91 | return href; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * |
| 96 | * @return HTTP method of the action this applies to |
| 97 | */ |
| 98 | public String getMethod() { |
| 99 | return method; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * |
| 104 | * @return name of the HTTP request parameter related to this |
| 105 | */ |
| 106 | public String getName() { |
| 107 | return name; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * |
| 112 | * @return name of the action this applies to |
| 113 | */ |
| 114 | public String getOperation() { |
| 115 | return operation; |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public String toString() { |
| 120 | return "[href=" + href + ", method=" + method + ", name=" + name + ", operation=" + operation + "]"; |
| 121 | } |
| 122 | } |