EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2.domain]

COVERAGE SUMMARY FOR SOURCE FILE [InstanceStateChange.java]

nameclass, %method, %block, %line, %
InstanceStateChange.java100% (1/1)33%  (3/9)56%  (119/211)54%  (25.6/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InstanceStateChange100% (1/1)33%  (3/9)56%  (119/211)54%  (25.6/47)
compareTo (InstanceStateChange): int 0%   (0/1)0%   (0/11)0%   (0/1)
getCurrentState (): InstanceState 0%   (0/1)0%   (0/3)0%   (0/1)
getInstanceId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getPreviousState (): InstanceState 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/27)0%   (0/1)
equals (Object): boolean 100% (1/1)60%  (51/85)46%  (13/28)
hashCode (): int 100% (1/1)86%  (50/58)94%  (6.6/7)
InstanceStateChange (String, String, InstanceState, InstanceState): void 100% (1/1)100% (18/18)100% (6/6)

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 */
19package org.jclouds.ec2.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23 
24/**
25 * 
26 * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-TerminateInstancesResponseInfoType.html"
27 *      />
28 * @author Adrian Cole
29 */
30public class InstanceStateChange implements Comparable<InstanceStateChange> {
31 
32   private final String region;
33   private final String instanceId;
34   private final InstanceState currentState;
35   private final InstanceState previousState;
36 
37   public int compareTo(InstanceStateChange o) {
38      return (this == o) ? 0 : getInstanceId().compareTo(o.getInstanceId());
39   }
40 
41   public InstanceStateChange(String region, String instanceId, InstanceState currentState,
42            InstanceState previousState) {
43      this.region = checkNotNull(region, "region");
44      this.instanceId = instanceId;
45      this.currentState = currentState;
46      this.previousState = previousState;
47   }
48 
49   /**
50    * Instances are tied to Availability Zones. However, the instance ID is tied to the Region.
51    */
52   public String getRegion() {
53      return region;
54   }
55 
56   public String getInstanceId() {
57      return instanceId;
58   }
59 
60   public InstanceState getCurrentState() {
61      return currentState;
62   }
63 
64   public InstanceState getPreviousState() {
65      return previousState;
66   }
67 
68   @Override
69   public int hashCode() {
70      final int prime = 31;
71      int result = 1;
72      result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
73      result = prime * result + ((previousState == null) ? 0 : previousState.hashCode());
74      result = prime * result + ((region == null) ? 0 : region.hashCode());
75      result = prime * result + ((currentState == null) ? 0 : currentState.hashCode());
76      return result;
77   }
78 
79   @Override
80   public boolean equals(Object obj) {
81      if (this == obj)
82         return true;
83      if (obj == null)
84         return false;
85      if (getClass() != obj.getClass())
86         return false;
87      InstanceStateChange other = (InstanceStateChange) obj;
88      if (instanceId == null) {
89         if (other.instanceId != null)
90            return false;
91      } else if (!instanceId.equals(other.instanceId))
92         return false;
93      if (previousState == null) {
94         if (other.previousState != null)
95            return false;
96      } else if (!previousState.equals(other.previousState))
97         return false;
98      if (region == null) {
99         if (other.region != null)
100            return false;
101      } else if (!region.equals(other.region))
102         return false;
103      if (currentState == null) {
104         if (other.currentState != null)
105            return false;
106      } else if (!currentState.equals(other.currentState))
107         return false;
108      return true;
109   }
110 
111   @Override
112   public String toString() {
113      return "InstanceStateChange [currentState=" + currentState + ", instanceId=" + instanceId
114               + ", previousState=" + previousState + ", region=" + region + "]";
115   }
116 
117}

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