EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.deltacloud.domain]

COVERAGE SUMMARY FOR SOURCE FILE [Instance.java]

nameclass, %method, %block, %line, %
Instance.java100% (3/3)54%  (15/28)81%  (351/432)57%  (38.9/68)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Instance100% (1/1)19%  (3/16)67%  (154/229)43%  (18.9/44)
equals (Object): boolean 0%   (0/1)0%   (0/37)0%   (0/13)
getActions (): Map 0%   (0/1)0%   (0/3)0%   (0/1)
getAuthentication (): Instance$Authentication 0%   (0/1)0%   (0/3)0%   (0/1)
getHardwareProfile (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getHref (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getImage (): URI 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)
getPrivateAddresses (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getPublicAddresses (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getRealm (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getState (): Instance$State 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 100% (1/1)89%  (17/19)97%  (3.9/4)
Instance (URI, String, String, String, URI, URI, URI, Instance$State, Map, In... 100% (1/1)100% (72/72)100% (14/14)
toString (): String 100% (1/1)100% (65/65)100% (1/1)
     
class Instance$State100% (1/1)100% (5/5)97%  (95/98)82%  (9/11)
fromValue (String): Instance$State 100% (1/1)70%  (7/10)33%  (1/3)
<static initializer> 100% (1/1)100% (74/74)100% (8/8)
Instance$State (String, int): void 100% (1/1)100% (5/5)100% (1/1)
valueOf (String): Instance$State 100% (1/1)100% (5/5)100% (1/1)
values (): Instance$State [] 100% (1/1)100% (4/4)100% (1/1)
     
class Instance$Action100% (1/1)100% (7/7)97%  (102/105)85%  (11/13)
fromValue (String): Instance$Action 100% (1/1)70%  (7/10)33%  (1/3)
<static initializer> 100% (1/1)100% (74/74)100% (8/8)
Instance$Action (String, int): void 100% (1/1)100% (5/5)100% (1/1)
toString (): String 100% (1/1)100% (3/3)100% (1/1)
value (): String 100% (1/1)100% (4/4)100% (1/1)
valueOf (String): Instance$Action 100% (1/1)100% (5/5)100% (1/1)
values (): Instance$Action [] 100% (1/1)100% (4/4)100% (1/1)

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.deltacloud.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Map;
25import java.util.Set;
26 
27import org.jclouds.javax.annotation.Nullable;
28 
29import org.jclouds.http.HttpRequest;
30 
31import com.google.common.collect.ImmutableMap;
32import com.google.common.collect.ImmutableSet;
33 
34/**
35 * An instance is a concrete machine realized from an image.
36 * 
37 * @author Adrian Cole
38 */
39public class Instance {
40   public static interface Authentication {
41 
42   }
43 
44   public static enum State {
45      /**
46       * initial state, before instance is created.
47       */
48      START,
49      /**
50       * the instance is in the process of being launched
51       */
52      PENDING,
53      /**
54       * the instance launched (although the boot process might not be completed)
55       */
56      RUNNING,
57      /**
58       * the instance is shutting down
59       */
60      SHUTTING_DOWN,
61      /**
62       * the instance is stopped
63       */
64      STOPPED,
65      /**
66       * the instance is terminated
67       */
68      FINISH,
69      /**
70       * state returned as something besides the above.
71       */
72      UNRECOGNIZED;
73 
74      public static State fromValue(String state) {
75         try {
76            return valueOf(checkNotNull(state, "state").toUpperCase());
77         } catch (IllegalArgumentException e) {
78            return UNRECOGNIZED;
79         }
80      }
81   }
82 
83   public static enum Action {
84 
85      CREATE,
86 
87      RUN,
88 
89      REBOOT,
90 
91      START,
92 
93      STOP,
94 
95      DESTROY,
96 
97      UNRECOGNIZED;
98 
99      public String value() {
100         return name().toLowerCase();
101      }
102 
103      @Override
104      public String toString() {
105         return value();
106      }
107 
108      public static Action fromValue(String action) {
109         try {
110            return valueOf(checkNotNull(action, "action").toUpperCase());
111         } catch (IllegalArgumentException e) {
112            return UNRECOGNIZED;
113         }
114      }
115   }
116 
117   private final URI href;
118   private final String id;
119   private final String ownerId;
120   @Nullable
121   private final String name;
122   private final URI image;
123   private final URI hardwareProfile;
124   private final URI realm;
125   private final State state;
126   private final Map<Action, HttpRequest> actions;
127   @Nullable
128   private final Authentication authentication;
129   private final Set<String> publicAddresses;
130   private final Set<String> privateAddresses;
131 
132   public Instance(URI href, String id, String ownerId, @Nullable String name, URI image, URI hardwareProfile,
133            URI realm, State state, Map<Action, HttpRequest> actions, @Nullable Authentication authentication,
134            Set<String> publicAddresses, Set<String> privateAddresses) {
135      this.href = checkNotNull(href, "href");
136      this.id = checkNotNull(id, "id");
137      this.ownerId = checkNotNull(ownerId, "ownerId");
138      this.name = name;
139      this.image = checkNotNull(image, "image");
140      this.hardwareProfile = checkNotNull(hardwareProfile, "hardwareProfile");
141      this.realm = checkNotNull(realm, "realm");
142      this.state = checkNotNull(state, "state");
143      this.actions = ImmutableMap.copyOf(checkNotNull(actions, "actions"));
144      this.authentication = authentication;
145      this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
146      this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
147   }
148 
149   /**
150    * 
151    * @return URL to manipulate a specific instance
152    */
153   public URI getHref() {
154      return href;
155   }
156 
157   /**
158    * 
159    * @return A unique identifier for the instance
160    */
161   public String getId() {
162      return id;
163   }
164 
165   /**
166    * 
167    * @return An opaque identifier which indicates the owner of an instance
168    */
169   public String getOwnerId() {
170      return ownerId;
171   }
172 
173   /**
174    * 
175    * @return An optional short label describing the instance
176    */
177   @Nullable
178   public String getName() {
179      return name;
180   }
181 
182   /**
183    * 
184    * @return
185    */
186   public URI getImage() {
187      return image;
188   }
189 
190   /**
191    * 
192    * @return a link to the hardware profile in use by the instance
193    */
194   public URI getHardwareProfile() {
195      return hardwareProfile;
196   }
197 
198   /**
199    * 
200    * @return a link to the realm where the instance is deployed
201    */
202   public URI getRealm() {
203      return realm;
204   }
205 
206   /**
207    * 
208    * @return indicator of the instance's current state
209    */
210   public State getState() {
211      return state;
212   }
213 
214   /**
215    * 
216    * @return valid actions for the instance, along with the URL which may be used to perform the
217    *         action
218    */
219   public Map<Action, HttpRequest> getActions() {
220      return actions;
221   }
222 
223   /**
224    * 
225    * @return authentication of the instance or null
226    */
227   @Nullable
228   public Authentication getAuthentication() {
229      return authentication;
230   }
231 
232   /**
233    * 
234    * @return publicly routable IP addresses or names for the instance
235    */
236   public Set<String> getPublicAddresses() {
237      return publicAddresses;
238   }
239 
240   /**
241    * 
242    * @return Private network IP addresses or names for the instance
243    */
244   public Set<String> getPrivateAddresses() {
245      return privateAddresses;
246   }
247 
248   @Override
249   public int hashCode() {
250      final int prime = 31;
251      int result = 1;
252      result = prime * result + ((href == null) ? 0 : href.hashCode());
253      return result;
254   }
255 
256   @Override
257   public boolean equals(Object obj) {
258      if (this == obj)
259         return true;
260      if (obj == null)
261         return false;
262      if (getClass() != obj.getClass())
263         return false;
264      Instance other = (Instance) obj;
265      if (href == null) {
266         if (other.href != null)
267            return false;
268      } else if (!href.equals(other.href))
269         return false;
270      return true;
271   }
272 
273   @Override
274   public String toString() {
275      return String
276               .format(
277                        "[id=%s, href=%s, image=%s, name=%s, state=%s, realm=%s, ownerId=%s, hardwareProfile=%s, actions=%s, authentication=%s, privateAddresses=%s, publicAddresses=%s]",
278                        id, href, image, name, state, realm, ownerId, hardwareProfile, actions, authentication,
279                        privateAddresses, publicAddresses);
280   }
281 
282}

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