EMMA Coverage Report (generated Mon Dec 09 15:12:29 EST 2013)
[all classes][org.jclouds.glesys.domain]

COVERAGE SUMMARY FOR SOURCE FILE [ServerSpec.java]

nameclass, %method, %block, %line, %
ServerSpec.java75%  (3/4)78%  (21/27)43%  (139/320)80%  (35/44)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ServerSpec100% (1/1)64%  (9/14)27%  (59/217)68%  (17/25)
equals (Object): boolean 0%   (0/1)0%   (0/73)0%   (0/4)
hashCode (): int 0%   (0/1)0%   (0/43)0%   (0/1)
string (): Objects$ToStringHelper 0%   (0/1)0%   (0/31)0%   (0/1)
toBuilder (): ServerSpec$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/4)0%   (0/1)
ServerSpec (String, String, int, int, String, int, int): void 100% (1/1)100% (33/33)100% (9/9)
builder (): ServerSpec$Builder 100% (1/1)100% (5/5)100% (1/1)
getCpuCores (): int 100% (1/1)100% (3/3)100% (1/1)
getDatacenter (): String 100% (1/1)100% (3/3)100% (1/1)
getDiskSizeGB (): int 100% (1/1)100% (3/3)100% (1/1)
getMemorySizeMB (): int 100% (1/1)100% (3/3)100% (1/1)
getPlatform (): String 100% (1/1)100% (3/3)100% (1/1)
getTemplateName (): String 100% (1/1)100% (3/3)100% (1/1)
getTransferGB (): int 100% (1/1)100% (3/3)100% (1/1)
     
class ServerSpec$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class ServerSpec$Builder100% (1/1)90%  (9/10)76%  (72/95)94%  (16/17)
fromServerSpec (ServerSpec): ServerSpec$Builder 0%   (0/1)0%   (0/23)0%   (0/1)
ServerSpec$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): ServerSpec 100% (1/1)100% (18/18)100% (1/1)
cpuCores (int): ServerSpec$Builder 100% (1/1)100% (6/6)100% (2/2)
datacenter (String): ServerSpec$Builder 100% (1/1)100% (9/9)100% (2/2)
diskSizeGB (int): ServerSpec$Builder 100% (1/1)100% (6/6)100% (2/2)
memorySizeMB (int): ServerSpec$Builder 100% (1/1)100% (6/6)100% (2/2)
platform (String): ServerSpec$Builder 100% (1/1)100% (9/9)100% (2/2)
templateName (String): ServerSpec$Builder 100% (1/1)100% (9/9)100% (2/2)
transferGB (int): ServerSpec$Builder 100% (1/1)100% (6/6)100% (2/2)
     
class ServerSpec$ConcreteBuilder100% (1/1)100% (3/3)100% (8/8)100% (2/2)
ServerSpec$ConcreteBuilder (): void 100% (1/1)100% (3/3)100% (1/1)
ServerSpec$ConcreteBuilder (ServerSpec$1): void 100% (1/1)100% (3/3)100% (1/1)
self (): ServerSpec$ConcreteBuilder 100% (1/1)100% (2/2)100% (1/1)

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package org.jclouds.glesys.domain;
18 
19import static com.google.common.base.Preconditions.checkNotNull;
20 
21import java.beans.ConstructorProperties;
22 
23import com.google.common.base.Objects;
24import com.google.common.base.Objects.ToStringHelper;
25 
26/**
27 * Class ServerSpec
28 *
29 * @author Adrian Cole
30 */
31public class ServerSpec {
32 
33   public static Builder<?> builder() {
34      return new ConcreteBuilder();
35   }
36 
37   public Builder<?> toBuilder() {
38      return new ConcreteBuilder().fromServerSpec(this);
39   }
40 
41   public abstract static class Builder<T extends Builder<T>> {
42      protected abstract T self();
43 
44      protected String platform;
45      protected String datacenter;
46      protected int memorySizeMB;
47      protected int diskSizeGB;
48      protected String templateName;
49      protected int cpuCores;
50      protected int transferGB;
51 
52      /**
53       * @see ServerSpec#getPlatform()
54       */
55      public T platform(String platform) {
56         this.platform = checkNotNull(platform, "platform");
57         return self();
58      }
59 
60      /**
61       * @see ServerSpec#getDatacenter()
62       */
63      public T datacenter(String datacenter) {
64         this.datacenter = checkNotNull(datacenter, "datacenter");
65         return self();
66      }
67 
68      /**
69       * @see ServerSpec#getMemorySizeMB()
70       */
71      public T memorySizeMB(int memorySizeMB) {
72         this.memorySizeMB = memorySizeMB;
73         return self();
74      }
75 
76      /**
77       * @see ServerSpec#getDiskSizeGB()
78       */
79      public T diskSizeGB(int diskSizeGB) {
80         this.diskSizeGB = diskSizeGB;
81         return self();
82      }
83 
84      /**
85       * @see ServerSpec#getTemplateName()
86       */
87      public T templateName(String templateName) {
88         this.templateName = checkNotNull(templateName, "templateName");
89         return self();
90      }
91 
92      /**
93       * @see ServerSpec#getCpuCores()
94       */
95      public T cpuCores(int cpuCores) {
96         this.cpuCores = cpuCores;
97         return self();
98      }
99 
100      /**
101       * @see ServerSpec#getTransferGB()
102       */
103      public T transferGB(int transferGB) {
104         this.transferGB = transferGB;
105         return self();
106      }
107 
108      public ServerSpec build() {
109         return new ServerSpec(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
110      }
111 
112      public T fromServerSpec(ServerSpec in) {
113         return this.platform(in.getPlatform())
114               .datacenter(in.getDatacenter())
115               .memorySizeMB(in.getMemorySizeMB())
116               .diskSizeGB(in.getDiskSizeGB())
117               .templateName(in.getTemplateName())
118               .cpuCores(in.getCpuCores())
119               .transferGB(in.getTransferGB());
120      }
121   }
122 
123   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
124      @Override
125      protected ConcreteBuilder self() {
126         return this;
127      }
128   }
129 
130   private final String platform;
131   private final String datacenter;
132   private final int memorySizeMB;
133   private final int diskSizeGB;
134   private final String templateName;
135   private final int cpuCores;
136   private final int transferGB;
137 
138   @ConstructorProperties({
139         "platform", "datacenter", "memorySizeMB", "diskSizeGB", "templateName", "cpuCores", "transferGB"
140   })
141   protected ServerSpec(String platform, String datacenter, int memorySizeMB, int diskSizeGB, String templateName, int cpuCores, int transferGB) {
142      this.platform = checkNotNull(platform, "platform");
143      this.datacenter = checkNotNull(datacenter, "datacenter");
144      this.memorySizeMB = memorySizeMB;
145      this.diskSizeGB = diskSizeGB;
146      this.templateName = checkNotNull(templateName, "templateName");
147      this.cpuCores = cpuCores;
148      this.transferGB = transferGB;
149   }
150 
151   /**
152    * @return the data center to create the new server in
153    */
154   public String getPlatform() {
155      return this.platform;
156   }
157 
158   /**
159    * @return the platform to use (i.e. "Xen" or "OpenVZ")
160    */
161   public String getDatacenter() {
162      return this.datacenter;
163   }
164 
165   /**
166    * @return the os template to use to create the new server
167    */
168   public int getMemorySizeMB() {
169      return this.memorySizeMB;
170   }
171 
172   /**
173    * @return the amount of disk space, in GB, to allocate
174    */
175   public int getDiskSizeGB() {
176      return this.diskSizeGB;
177   }
178 
179   /**
180    * @return the memory, in MB, to allocate
181    */
182   public String getTemplateName() {
183      return this.templateName;
184   }
185 
186   /**
187    * @return the number of CPU cores to allocate
188    */
189   public int getCpuCores() {
190      return this.cpuCores;
191   }
192 
193   /**
194    * @return bandwidth of in GB
195    */
196   public int getTransferGB() {
197      return this.transferGB;
198   }
199 
200   @Override
201   public int hashCode() {
202      return Objects.hashCode(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
203   }
204 
205   @Override
206   public boolean equals(Object obj) {
207      if (this == obj) return true;
208      if (obj == null || getClass() != obj.getClass()) return false;
209      ServerSpec that = ServerSpec.class.cast(obj);
210      return Objects.equal(this.platform, that.platform)
211            && Objects.equal(this.datacenter, that.datacenter)
212            && Objects.equal(this.memorySizeMB, that.memorySizeMB)
213            && Objects.equal(this.diskSizeGB, that.diskSizeGB)
214            && Objects.equal(this.templateName, that.templateName)
215            && Objects.equal(this.cpuCores, that.cpuCores)
216            && Objects.equal(this.transferGB, that.transferGB);
217   }
218 
219   protected ToStringHelper string() {
220      return Objects.toStringHelper("").add("platform", platform).add("datacenter", datacenter)
221            .add("memorySizeMB", memorySizeMB).add("diskSizeGB", diskSizeGB).add("templateName", templateName)
222            .add("cpuCores", cpuCores).add("transferGB", transferGB);
223   }
224 
225   @Override
226   public String toString() {
227      return string().toString();
228   }
229}

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