View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * 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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.vcloud.terremark.domain;
20  
21  import java.net.URI;
22  
23  /**
24   * @author Adrian Cole
25   */
26  public class InternetService implements Comparable<InternetService> {
27     private final String name;
28     private final URI id;
29     private final PublicIpAddress publicIpAddress;
30     private final int port;
31     private final Protocol protocol;
32     private final boolean enabled;
33     private final int timeout;
34     private final String description;
35  
36     public InternetService(String name, URI id, PublicIpAddress publicIpAddress, int port, Protocol protocol,
37           boolean enabled, int timeout, String description) {
38        this.name = name;
39        this.id = id;
40        this.publicIpAddress = publicIpAddress;
41        this.port = port;
42        this.protocol = protocol;
43        this.enabled = enabled;
44        this.timeout = timeout;
45        this.description = description;
46     }
47  
48     public PublicIpAddress getPublicIpAddress() {
49        return publicIpAddress;
50     }
51  
52     public int getPort() {
53        return port;
54     }
55  
56     public Protocol getProtocol() {
57        return protocol;
58     }
59  
60     public boolean isEnabled() {
61        return enabled;
62     }
63  
64     public int getTimeout() {
65        return timeout;
66     }
67  
68     public String getDescription() {
69        return description;
70     }
71  
72     public String getName() {
73        return name;
74     }
75  
76     public URI getId() {
77        return id;
78     }
79  
80     public int compareTo(InternetService that) {
81        return (this == that) ? 0 : getId().compareTo(that.getId());
82     }
83  
84     @Override
85     public String toString() {
86        return "InternetService [description=" + description + ", enabled=" + enabled + ", id=" + id + ", name="
87              + name + ", port=" + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress
88              + ", timeout=" + timeout + "]";
89     }
90  
91     @Override
92     public int hashCode() {
93        final int prime = 31;
94        int result = 1;
95        result = prime * result + ((description == null) ? 0 : description.hashCode());
96        result = prime * result + (enabled ? 1231 : 1237);
97        result = prime * result + ((id == null) ? 0 : id.hashCode());
98        result = prime * result + ((name == null) ? 0 : name.hashCode());
99        result = prime * result + port;
100       result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
101       result = prime * result + ((publicIpAddress == null) ? 0 : publicIpAddress.hashCode());
102       result = prime * result + timeout;
103       return result;
104    }
105 
106    @Override
107    public boolean equals(Object obj) {
108       if (this == obj)
109          return true;
110       if (obj == null)
111          return false;
112       if (getClass() != obj.getClass())
113          return false;
114       InternetService other = (InternetService) obj;
115       if (description == null) {
116          if (other.description != null)
117             return false;
118       } else if (!description.equals(other.description))
119          return false;
120       if (enabled != other.enabled)
121          return false;
122       if (id == null) {
123          if (other.id != null)
124             return false;
125       } else if (!id.equals(other.id))
126          return false;
127       if (name == null) {
128          if (other.name != null)
129             return false;
130       } else if (!name.equals(other.name))
131          return false;
132       if (port != other.port)
133          return false;
134       if (protocol == null) {
135          if (other.protocol != null)
136             return false;
137       } else if (!protocol.equals(other.protocol))
138          return false;
139       if (publicIpAddress == null) {
140          if (other.publicIpAddress != null)
141             return false;
142       } else if (!publicIpAddress.equals(other.publicIpAddress))
143          return false;
144       if (timeout != other.timeout)
145          return false;
146       return true;
147    }
148 
149 }