EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [SecurityGroup.java]

nameclass, %method, %block, %line, %
SecurityGroup.java100% (1/1)30%  (3/10)57%  (142/251)54%  (29.5/55)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SecurityGroup100% (1/1)30%  (3/10)57%  (142/251)54%  (29.5/55)
compareTo (SecurityGroup): int 0%   (0/1)0%   (0/11)0%   (0/1)
getDescription (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getIpPermissions (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getOwnerId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRegion (): String 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/32)0%   (0/1)
equals (Object): boolean 100% (1/1)59%  (60/101)45%  (15/33)
hashCode (): int 100% (1/1)86%  (61/71)94%  (7.5/8)
SecurityGroup (String, String, String, String, Set): void 100% (1/1)100% (21/21)100% (7/7)

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 */
19package org.jclouds.ec2.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Set;
24 
25/**
26 * 
27 * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SecurityGroupItemType.html"
28 *      />
29 * @author Adrian Cole
30 */
31public class SecurityGroup implements Comparable<SecurityGroup> {
32 
33   private final String region;
34   private final String name;
35   private final String ownerId;
36   private final String description;
37   private final Set<IpPermission> ipPermissions;
38 
39   public SecurityGroup(String region, String name, String ownerId, String description,
40            Set<IpPermission> ipPermissions) {
41      this.region = checkNotNull(region, "region");
42      this.name = name;
43      this.ownerId = ownerId;
44      this.description = description;
45      this.ipPermissions = ipPermissions;
46   }
47 
48   /**
49    * Security groups are not copied across Regions. Instances within the Region cannot communicate
50    * with instances outside the Region using group-based firewall rules. Traffic from instances in
51    * another Region is seen as WAN bandwidth.
52    */
53   public String getRegion() {
54      return region;
55   }
56 
57   /**
58    * {@inheritDoc}
59    */
60   public int compareTo(SecurityGroup o) {
61      return (this == o) ? 0 : getName().compareTo(o.getName());
62   }
63 
64   /**
65    * Name of the security group.
66    */
67   public String getName() {
68      return name;
69   }
70 
71   /**
72    * AWS Access Key ID of the owner of the security group.
73    */
74   public String getOwnerId() {
75      return ownerId;
76   }
77 
78   /**
79    * Description of the security group.
80    */
81   public String getDescription() {
82      return description;
83   }
84 
85   /**
86    * Set of IP permissions associated with the security group.
87    */
88   public Set<IpPermission> getIpPermissions() {
89      return ipPermissions;
90   }
91 
92   @Override
93   public int hashCode() {
94      final int prime = 31;
95      int result = 1;
96      result = prime * result + ((description == null) ? 0 : description.hashCode());
97      result = prime * result + ((ipPermissions == null) ? 0 : ipPermissions.hashCode());
98      result = prime * result + ((name == null) ? 0 : name.hashCode());
99      result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
100      result = prime * result + ((region == null) ? 0 : region.hashCode());
101      return result;
102   }
103 
104   @Override
105   public boolean equals(Object obj) {
106      if (this == obj)
107         return true;
108      if (obj == null)
109         return false;
110      if (getClass() != obj.getClass())
111         return false;
112      SecurityGroup other = (SecurityGroup) obj;
113      if (description == null) {
114         if (other.description != null)
115            return false;
116      } else if (!description.equals(other.description))
117         return false;
118      if (ipPermissions == null) {
119         if (other.ipPermissions != null)
120            return false;
121      } else if (!ipPermissions.equals(other.ipPermissions))
122         return false;
123      if (name == null) {
124         if (other.name != null)
125            return false;
126      } else if (!name.equals(other.name))
127         return false;
128      if (ownerId == null) {
129         if (other.ownerId != null)
130            return false;
131      } else if (!ownerId.equals(other.ownerId))
132         return false;
133      if (region == null) {
134         if (other.region != null)
135            return false;
136      } else if (!region.equals(other.region))
137         return false;
138      return true;
139   }
140 
141   @Override
142   public String toString() {
143      return "SecurityGroup [description=" + description + ", ipPermissions=" + ipPermissions
144               + ", name=" + name + ", ownerId=" + ownerId + ", region=" + region + "]";
145   }
146}

[all classes][org.jclouds.ec2.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov