View Javadoc

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  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 "[description=" + description + ", enabled=" + enabled + ", id=" + id + ", name=" + name + ", port="
87              + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress + ", timeout=" + timeout + "]";
88     }
89  
90     @Override
91     public int hashCode() {
92        final int prime = 31;
93        int result = 1;
94        result = prime * result + ((description == null) ? 0 : description.hashCode());
95        result = prime * result + (enabled ? 1231 : 1237);
96        result = prime * result + ((id == null) ? 0 : id.hashCode());
97        result = prime * result + ((name == null) ? 0 : name.hashCode());
98        result = prime * result + port;
99        result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
100       result = prime * result + ((publicIpAddress == null) ? 0 : publicIpAddress.hashCode());
101       result = prime * result + timeout;
102       return result;
103    }
104 
105    @Override
106    public boolean equals(Object obj) {
107       if (this == obj)
108          return true;
109       if (obj == null)
110          return false;
111       if (getClass() != obj.getClass())
112          return false;
113       InternetService other = (InternetService) obj;
114       if (description == null) {
115          if (other.description != null)
116             return false;
117       } else if (!description.equals(other.description))
118          return false;
119       if (enabled != other.enabled)
120          return false;
121       if (id == null) {
122          if (other.id != null)
123             return false;
124       } else if (!id.equals(other.id))
125          return false;
126       if (name == null) {
127          if (other.name != null)
128             return false;
129       } else if (!name.equals(other.name))
130          return false;
131       if (port != other.port)
132          return false;
133       if (protocol == null) {
134          if (other.protocol != null)
135             return false;
136       } else if (!protocol.equals(other.protocol))
137          return false;
138       if (publicIpAddress == null) {
139          if (other.publicIpAddress != null)
140             return false;
141       } else if (!publicIpAddress.equals(other.publicIpAddress))
142          return false;
143       if (timeout != other.timeout)
144          return false;
145       return true;
146    }
147 
148 }