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

COVERAGE SUMMARY FOR SOURCE FILE [Realm.java]

nameclass, %method, %block, %line, %
Realm.java100% (2/2)57%  (8/14)67%  (199/297)59%  (34.4/58)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Realm100% (1/1)33%  (3/9)60%  (145/240)58%  (29.4/51)
getHref (): URI 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getLimit (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getState (): Realm$State 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)60%  (55/92)50%  (15/30)
hashCode (): int 100% (1/1)85%  (60/71)93%  (7.4/8)
Realm (URI, String, String, String, Realm$State): void 100% (1/1)100% (30/30)100% (7/7)
     
class Realm$State100% (1/1)100% (5/5)95%  (54/57)71%  (5/7)
fromValue (String): Realm$State 100% (1/1)67%  (6/9)33%  (1/3)
<static initializer> 100% (1/1)100% (34/34)100% (4/4)
Realm$State (String, int): void 100% (1/1)100% (5/5)100% (1/1)
valueOf (String): Realm$State 100% (1/1)100% (5/5)100% (1/1)
values (): Realm$State [] 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;
24 
25import org.jclouds.javax.annotation.Nullable;
26 
27/**
28 * Within a cloud provider a realm represents a boundary containing resources. The exact definition
29 * of a realm is left to the cloud provider. In some cases, a realm may represent different
30 * datacenters, different continents, or different pools of resources within a single datacenter. A
31 * cloud provider may insist that resources must all exist within a single realm in order to
32 * cooperate. For instance, storage volumes may only be allowed to be mounted to instances within
33 * the same realm.
34 * 
35 * @author Adrian Cole
36 */
37public class Realm {
38   public enum State {
39 
40      /**
41       * the realm is available
42       */
43      AVAILABLE,
44 
45      /**
46       * the realm is unavailable
47       */
48      UNAVAILABLE,
49 
50      /**
51       * state returned as something besides the above.
52       */
53      UNRECOGNIZED;
54 
55      public static State fromValue(String state) {
56         try {
57            return valueOf(checkNotNull(state, "state"));
58         } catch (IllegalArgumentException e) {
59            return UNRECOGNIZED;
60         }
61      }
62   }
63   private final URI href;
64   private final String id;
65   @Nullable
66   private final String limit;
67   private final String name;
68   private final State state;
69 
70   public Realm(URI href, String id, String name, @Nullable String limit, State state) {
71      this.href = checkNotNull(href, "href");
72      this.id = checkNotNull(id, "id");
73      this.name = checkNotNull(name, "name");
74      this.limit = limit;
75      this.state = checkNotNull(state, "state");
76   }
77 
78   /**
79    * 
80    * @return URL to manipulate a specific realm
81    */
82   public URI getHref() {
83      return href;
84   }
85 
86   /**
87    * 
88    * @return A unique identifier for the realm
89    */
90   public String getId() {
91      return id;
92   }
93 
94   /**
95    * 
96    * @return A short label
97    */
98   public String getName() {
99      return name;
100   }
101 
102   /**
103    * for example limitation of how many machine you can launch in given region / how much computing
104    * power is available for you.
105    * 
106    * @return Limits applicable for the current requester
107    */
108   @Nullable
109   public String getLimit() {
110      return limit;
111   }
112 
113   /**
114    * 
115    * @return indicator of the realm's current state
116    */
117   public State getState() {
118      return state;
119   }
120 
121   @Override
122   public int hashCode() {
123      final int prime = 31;
124      int result = 1;
125      result = prime * result + ((href == null) ? 0 : href.hashCode());
126      result = prime * result + ((id == null) ? 0 : id.hashCode());
127      result = prime * result + ((limit == null) ? 0 : limit.hashCode());
128      result = prime * result + ((name == null) ? 0 : name.hashCode());
129      result = prime * result + ((state == null) ? 0 : state.hashCode());
130      return result;
131   }
132 
133   @Override
134   public boolean equals(Object obj) {
135      if (this == obj)
136         return true;
137      if (obj == null)
138         return false;
139      if (getClass() != obj.getClass())
140         return false;
141      Realm other = (Realm) obj;
142      if (href == null) {
143         if (other.href != null)
144            return false;
145      } else if (!href.equals(other.href))
146         return false;
147      if (id == null) {
148         if (other.id != null)
149            return false;
150      } else if (!id.equals(other.id))
151         return false;
152      if (limit == null) {
153         if (other.limit != null)
154            return false;
155      } else if (!limit.equals(other.limit))
156         return false;
157      if (name == null) {
158         if (other.name != null)
159            return false;
160      } else if (!name.equals(other.name))
161         return false;
162      if (state != other.state)
163         return false;
164      return true;
165   }
166 
167   @Override
168   public String toString() {
169      return "[href=" + href + ", id=" + id + ", limit=" + limit + ", name=" + name + ", state=" + state + "]";
170   }
171 
172}

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