| 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 | * @author Seshu Pasam |
| 23 | */ |
| 24 | public class NetworkAdapter implements Comparable<NetworkAdapter> { |
| 25 | private final String macAddress; |
| 26 | private final String name; |
| 27 | private final Subnet subnet; |
| 28 | |
| 29 | public NetworkAdapter(String macAddress, String name, Subnet subnet) { |
| 30 | this.macAddress = macAddress; |
| 31 | this.name = name; |
| 32 | this.subnet = subnet; |
| 33 | } |
| 34 | |
| 35 | public int compareTo(NetworkAdapter that) { |
| 36 | return (this == that) ? 0 : getMacAddress().compareTo(that.getMacAddress()); |
| 37 | } |
| 38 | |
| 39 | public String getMacAddress() { |
| 40 | return macAddress; |
| 41 | } |
| 42 | |
| 43 | public String getName() { |
| 44 | return name; |
| 45 | } |
| 46 | |
| 47 | public Subnet getSubnet() { |
| 48 | return subnet; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public int hashCode() { |
| 53 | final int prime = 31; |
| 54 | int result = 1; |
| 55 | result = prime * result + ((macAddress== null) ? 0 : macAddress.hashCode()); |
| 56 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 57 | result = prime * result + ((subnet == null) ? 0 : subnet.hashCode()); |
| 58 | return result; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object obj) { |
| 63 | if (this == obj) |
| 64 | return true; |
| 65 | if (obj == null) |
| 66 | return false; |
| 67 | if (getClass() != obj.getClass()) |
| 68 | return false; |
| 69 | NetworkAdapter other = (NetworkAdapter) obj; |
| 70 | if (macAddress == null) { |
| 71 | if (other.macAddress != null) |
| 72 | return false; |
| 73 | } else if (!macAddress.equals(other.macAddress)) |
| 74 | return false; |
| 75 | if (name == null) { |
| 76 | if (other.name != null) |
| 77 | return false; |
| 78 | } else if (!name.equals(other.name)) |
| 79 | return false; |
| 80 | if (subnet == null) { |
| 81 | if (other.subnet != null) |
| 82 | return false; |
| 83 | } else if (!subnet.equals(other.subnet)) |
| 84 | return false; |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public String toString() { |
| 90 | return "[MAC address=" + macAddress + ", name=" + name + ", subnet=" + subnet + "]"; |
| 91 | } |
| 92 | } |