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

COVERAGE SUMMARY FOR SOURCE FILE [Datacenter.java]

nameclass, %method, %block, %line, %
Datacenter.java100% (2/2)59%  (13/22)56%  (125/225)55%  (28/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Datacenter$Builder100% (1/1)67%  (6/9)55%  (43/78)71%  (12/17)
fromDatacenter (Datacenter): Datacenter$Builder 0%   (0/1)0%   (0/17)0%   (0/1)
region (Region): Datacenter$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
regions (Iterable): Datacenter$Builder 0%   (0/1)0%   (0/9)0%   (0/2)
Datacenter$Builder (): void 100% (1/1)100% (9/9)100% (3/3)
build (): Datacenter 100% (1/1)100% (14/14)100% (1/1)
id (int): Datacenter$Builder 100% (1/1)100% (5/5)100% (2/2)
locationAddress (Address): Datacenter$Builder 100% (1/1)100% (5/5)100% (2/2)
longName (String): Datacenter$Builder 100% (1/1)100% (5/5)100% (2/2)
name (String): Datacenter$Builder 100% (1/1)100% (5/5)100% (2/2)
     
class Datacenter100% (1/1)54%  (7/13)56%  (82/147)47%  (16/34)
compareTo (Datacenter): int 0%   (0/1)0%   (0/10)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/28)0%   (0/10)
getName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getRegions (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/18)0%   (0/4)
toBuilder (): Datacenter$Builder 0%   (0/1)0%   (0/3)0%   (0/1)
Datacenter (): void 100% (1/1)100% (9/9)100% (4/4)
Datacenter (int, String, String, Address, Iterable): void 100% (1/1)100% (28/28)100% (9/9)
builder (): Datacenter$Builder 100% (1/1)100% (4/4)100% (1/1)
getId (): int 100% (1/1)100% (3/3)100% (1/1)
getLocationAddress (): Address 100% (1/1)100% (3/3)100% (1/1)
getLongName (): String 100% (1/1)100% (3/3)100% (1/1)
toString (): String 100% (1/1)100% (32/32)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.softlayer.domain;
20 
21import com.google.common.collect.ImmutableSet;
22import com.google.common.collect.Sets;
23 
24import java.util.Set;
25 
26import static com.google.common.base.Preconditions.checkNotNull;
27 
28/**
29 * 
30 * @author Adrian Cole
31 * @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Location_Datacenter"
32 *      />
33 */
34public class Datacenter implements Comparable<Datacenter> {
35   public static Builder builder() {
36      return new Builder();
37   }
38 
39   public static class Builder {
40      private int id = -1;
41      private String name;
42      private String longName;
43      private Address locationAddress;
44      private Set<Region> regions = Sets.newLinkedHashSet();
45 
46      public Builder id(int id) {
47         this.id = id;
48         return this;
49      }
50 
51      public Builder name(String name) {
52         this.name = name;
53         return this;
54      }
55 
56      public Builder longName(String longName) {
57         this.longName = longName;
58         return this;
59      }
60 
61      public Builder locationAddress(Address locationAddress) {
62         this.locationAddress = locationAddress;
63         return this;
64      }
65 
66      public Builder region(Region regions) {
67         this.regions.add(checkNotNull(regions, "regions"));
68         return this;
69      }
70 
71      public Builder regions(Iterable<Region> regions) {
72         this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
73         return this;
74      }
75 
76      public Datacenter build() {
77         return new Datacenter(id, name, longName, locationAddress, regions);
78      }
79 
80      public static Builder fromDatacenter(Datacenter in) {
81         return Datacenter.builder().id(in.getId()).name(in.getName())
82               .longName(in.getLongName()).locationAddress(in.getLocationAddress())
83               .regions(in.getRegions());
84      }
85   }
86 
87   private int id = -1;
88   private String name;
89   private String longName;
90   private Address locationAddress;
91   private Set<Region> regions = Sets.newLinkedHashSet();
92   // for deserializer
93   Datacenter() {
94 
95   }
96 
97   public Datacenter(int id, String name, String longName, Address locationAddress, Iterable<Region> regions) {
98      this.id = id;
99      this.name = name;
100      this.longName = longName;
101      this.locationAddress = locationAddress;
102      this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
103   }
104 
105   @Override
106   public int compareTo(Datacenter arg0) {
107      return new Integer(id).compareTo(arg0.getId());
108   }
109 
110   /**
111    * @return The unique identifier of a specific location.
112    */
113   public int getId() {
114      return id;
115   }
116 
117   /**
118    * @return A short location description.
119    */
120   public String getName() {
121      return name;
122   }
123 
124   /**
125    * @return A longer location description.
126    */
127   public String getLongName() {
128      return longName;
129   }
130 
131   /**
132    * @return A location's physical address (optional).
133    */
134   public Address getLocationAddress() {
135      return locationAddress;
136   }
137 
138   /**
139    * A location can be a member of 1 or more regions.
140    * Sometimes the list of regions is empty, for example as a new Datacenter is being added.
141    * The list of regions usually contains one with keyName=FIRST_AVAILABLE which should be ignored.
142    * @return The regions to which a location belongs.
143    */
144   public Set<Region> getRegions() {
145      return regions;
146   }
147 
148   public Builder toBuilder() {
149      return Builder.fromDatacenter(this);
150   }
151 
152   @Override
153   public int hashCode() {
154      final int prime = 31;
155      int result = 1;
156      result = prime * result + (id ^ (id >>> 32));
157      return result;
158   }
159 
160   @Override
161   public boolean equals(Object obj) {
162      if (this == obj)
163         return true;
164      if (obj == null)
165         return false;
166      if (getClass() != obj.getClass())
167         return false;
168      Datacenter other = (Datacenter) obj;
169      if (id != other.id)
170         return false;
171      return true;
172   }
173 
174   @Override
175   public String toString() {
176      return "[id=" + id + ", country=" + name + ", state=" + longName + "], locationAddress=" + locationAddress + ", regions="+regions+"]";
177   }
178   
179   
180}

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