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.domain.network;
20  
21  import javax.annotation.Nullable;
22  
23  /**
24   * The Features element defines the DHCP and firewall features of a network.
25   */
26  public class Features {
27     @Nullable
28     private final DhcpService dhcpService;
29     @Nullable
30     private final FirewallService firewallService;
31     @Nullable
32     private final NatService natService;
33  
34     public Features(@Nullable DhcpService dhcpService, @Nullable FirewallService firewallService,
35              @Nullable NatService natService) {
36        this.dhcpService = dhcpService;
37        this.firewallService = firewallService;
38        this.natService = natService;
39     }
40  
41     /**
42      * specifies the properties of the network’s DHCP service
43      * 
44      * @since vcloud api 0.9, but emulated for 0.8
45      */
46     @Nullable
47     public DhcpService getDhcpService() {
48        return dhcpService;
49     }
50  
51     /**
52      * defines the firewall service capabilities of the network
53      * 
54      * @since vcloud api 0.8
55      */
56     @Nullable
57     public FirewallService getFirewallService() {
58        return firewallService;
59     }
60  
61     /**
62      * defines the NAT service capabilities of the network
63      * 
64      * @since vcloud api 0.8
65      */
66     @Nullable
67     public NatService getNatService() {
68        return natService;
69     }
70  
71     @Override
72     public int hashCode() {
73        final int prime = 31;
74        int result = 1;
75        result = prime * result + ((dhcpService == null) ? 0 : dhcpService.hashCode());
76        result = prime * result + ((firewallService == null) ? 0 : firewallService.hashCode());
77        result = prime * result + ((natService == null) ? 0 : natService.hashCode());
78        return result;
79     }
80  
81     @Override
82     public boolean equals(Object obj) {
83        if (this == obj)
84           return true;
85        if (obj == null)
86           return false;
87        if (getClass() != obj.getClass())
88           return false;
89        Features other = (Features) obj;
90        if (dhcpService == null) {
91           if (other.dhcpService != null)
92              return false;
93        } else if (!dhcpService.equals(other.dhcpService))
94           return false;
95        if (firewallService == null) {
96           if (other.firewallService != null)
97              return false;
98        } else if (!firewallService.equals(other.firewallService))
99           return false;
100       if (natService == null) {
101          if (other.natService != null)
102             return false;
103       } else if (!natService.equals(other.natService))
104          return false;
105       return true;
106    }
107 
108    @Override
109    public String toString() {
110       return "[dhcpService=" + dhcpService + ", firewallService=" + firewallService + ", natService=" + natService
111                + "]";
112    }
113 
114 }