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.firewall;
20  
21  /**
22   * The Protocols element specifies the protocols to which firewall rules apply.
23   * 
24   * @since vcloud api 0.9 emulated for 0.8
25   * 
26   * 
27   */
28  public class FirewallProtocols {
29     private final boolean tcp;
30     private final boolean udp;
31  
32     public FirewallProtocols(boolean tcp, boolean udp) {
33        this.tcp = tcp;
34        this.udp = udp;
35     }
36  
37     /**
38      * @return true if the firewall rules apply to the TCP protocol
39      */
40     public boolean isTcp() {
41        return tcp;
42     }
43  
44     /**
45      * @return true if the firewall rules apply to the UDP protocol
46      */
47     public boolean isUdp() {
48        return udp;
49     }
50  
51     @Override
52     public int hashCode() {
53        final int prime = 31;
54        int result = 1;
55        result = prime * result + (tcp ? 1231 : 1237);
56        result = prime * result + (udp ? 1231 : 1237);
57        return result;
58     }
59  
60     @Override
61     public boolean equals(Object obj) {
62        if (this == obj)
63           return true;
64        if (obj == null)
65           return false;
66        if (getClass() != obj.getClass())
67           return false;
68        FirewallProtocols other = (FirewallProtocols) obj;
69        if (tcp != other.tcp)
70           return false;
71        if (udp != other.udp)
72           return false;
73        return true;
74     }
75  
76     @Override
77     public String toString() {
78        return "Protocols [tcp=" + tcp + ", udp=" + udp + "]";
79     }
80  
81  }