1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.trmk.vcloud_0_8.domain;
20
21 import java.net.URI;
22
23
24
25
26 public class Node implements Comparable<Node> {
27 private final String name;
28 private final URI id;
29 private final String ipAddress;
30 private final int port;
31 private final boolean enabled;
32 private final String description;
33
34 public Node(String name, URI id, String ipAddress, int port, boolean enabled, String description) {
35 this.name = name;
36 this.id = id;
37 this.ipAddress = ipAddress;
38 this.port = port;
39 this.enabled = enabled;
40 this.description = description;
41 }
42
43 public int getPort() {
44 return port;
45 }
46
47 public boolean isEnabled() {
48 return enabled;
49 }
50
51 public String getDescription() {
52 return description;
53 }
54
55 public String getName() {
56 return name;
57 }
58
59 public URI getId() {
60 return id;
61 }
62
63 public String getIpAddress() {
64 return ipAddress;
65 }
66
67 public int compareTo(Node that) {
68 return (this == that) ? 0 : getId().compareTo(that.getId());
69 }
70
71 @Override
72 public String toString() {
73 return "Node [id=" + id + ", name=" + name + ", description=" + description + ", ipAddress=" + ipAddress
74 + ", port=" + port + ", enabled=" + enabled + "]";
75 }
76
77 @Override
78 public int hashCode() {
79 final int prime = 31;
80 int result = 1;
81 result = prime * result + ((description == null) ? 0 : description.hashCode());
82 result = prime * result + (enabled ? 1231 : 1237);
83 result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
84 result = prime * result + ((id == null) ? 0 : id.hashCode());
85 result = prime * result + ((name == null) ? 0 : name.hashCode());
86 result = prime * result + port;
87 return result;
88 }
89
90 @Override
91 public boolean equals(Object obj) {
92 if (this == obj)
93 return true;
94 if (obj == null)
95 return false;
96 if (getClass() != obj.getClass())
97 return false;
98 Node other = (Node) obj;
99 if (description == null) {
100 if (other.description != null)
101 return false;
102 } else if (!description.equals(other.description))
103 return false;
104 if (enabled != other.enabled)
105 return false;
106 if (ipAddress == null) {
107 if (other.ipAddress != null)
108 return false;
109 } else if (!ipAddress.equals(other.ipAddress))
110 return false;
111 if (id == null) {
112 if (other.id != null)
113 return false;
114 } else if (!id.equals(other.id))
115 return false;
116 if (name == null) {
117 if (other.name != null)
118 return false;
119 } else if (!name.equals(other.name))
120 return false;
121 if (port != other.port)
122 return false;
123 return true;
124 }
125 }