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

COVERAGE SUMMARY FOR SOURCE FILE [Server.java]

nameclass, %method, %block, %line, %
Server.java80%  (4/5)89%  (25/28)86%  (223/260)86%  (33.4/39)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Server$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class Server$Builder100% (1/1)86%  (6/7)78%  (51/65)91%  (10/11)
fromServer (Server): Server$Builder 0%   (0/1)0%   (0/14)0%   (0/1)
Server$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): Server 100% (1/1)100% (12/12)100% (1/1)
datacenter (String): Server$Builder 100% (1/1)100% (9/9)100% (2/2)
hostname (String): Server$Builder 100% (1/1)100% (9/9)100% (2/2)
id (String): Server$Builder 100% (1/1)100% (9/9)100% (2/2)
platform (String): Server$Builder 100% (1/1)100% (9/9)100% (2/2)
     
class Server100% (1/1)82%  (9/11)81%  (88/108)86%  (16.4/19)
hashCode (): int 0%   (0/1)0%   (0/9)0%   (0/1)
toBuilder (): Server$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
equals (Object): boolean 100% (1/1)84%  (21/25)84%  (3.4/4)
Server (String, String, String, String): void 100% (1/1)100% (27/27)100% (6/6)
builder (): Server$Builder 100% (1/1)100% (5/5)100% (1/1)
getDatacenter (): String 100% (1/1)100% (3/3)100% (1/1)
getHostname (): String 100% (1/1)100% (3/3)100% (1/1)
getId (): String 100% (1/1)100% (3/3)100% (1/1)
getPlatform (): String 100% (1/1)100% (3/3)100% (1/1)
string (): Objects$ToStringHelper 100% (1/1)100% (19/19)100% (1/1)
toString (): String 100% (1/1)100% (4/4)100% (1/1)
     
class Server$State100% (1/1)100% (7/7)96%  (76/79)71%  (5/7)
fromValue (String): Server$State 100% (1/1)75%  (9/12)33%  (1/3)
<static initializer> 100% (1/1)100% (44/44)100% (2/2)
Server$State (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% (6/6)100% (1/1)
valueOf (String): Server$State 100% (1/1)100% (5/5)100% (1/1)
values (): Server$State [] 100% (1/1)100% (4/4)100% (1/1)
     
class Server$ConcreteBuilder100% (1/1)100% (3/3)100% (8/8)100% (2/2)
Server$ConcreteBuilder (): void 100% (1/1)100% (3/3)100% (1/1)
Server$ConcreteBuilder (Server$1): void 100% (1/1)100% (3/3)100% (1/1)
self (): Server$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.CaseFormat;
24import com.google.common.base.Objects;
25import com.google.common.base.Objects.ToStringHelper;
26 
27/**
28 * Listing of a server.
29 *
30 * @author Adrian Cole
31 * @see <a href= "https://customer.glesys.com/api.php?a=doc#server_list" />
32 */
33public class Server {
34 
35   /**
36    */
37   public static enum State {
38 
39      RUNNING, LOCKED, STOPPED, UNRECOGNIZED;
40 
41      public String value() {
42         return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
43      }
44 
45      @Override
46      public String toString() {
47         return value();
48      }
49 
50      public static State fromValue(String state) {
51         try {
52            return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
53         } catch (IllegalArgumentException e) {
54            return UNRECOGNIZED;
55         }
56      }
57   }
58 
59   public static Builder<?> builder() {
60      return new ConcreteBuilder();
61   }
62 
63   public Builder<?> toBuilder() {
64      return new ConcreteBuilder().fromServer(this);
65   }
66 
67   public abstract static class Builder<T extends Builder<T>> {
68      protected abstract T self();
69 
70      protected String id;
71      protected String hostname;
72      protected String datacenter;
73      protected String platform;
74 
75      /**
76       * @see Server#getId()
77       */
78      public T id(String id) {
79         this.id = checkNotNull(id, "id");
80         return self();
81      }
82 
83      /**
84       * @see Server#getHostname()
85       */
86      public T hostname(String hostname) {
87         this.hostname = checkNotNull(hostname, "hostname");
88         return self();
89      }
90 
91      /**
92       * @see Server#getDatacenter()
93       */
94      public T datacenter(String datacenter) {
95         this.datacenter = checkNotNull(datacenter, "datacenter");
96         return self();
97      }
98 
99      /**
100       * @see Server#getPlatform()
101       */
102      public T platform(String platform) {
103         this.platform = checkNotNull(platform, "platform");
104         return self();
105      }
106 
107      public Server build() {
108         return new Server(id, hostname, datacenter, platform);
109      }
110 
111      public T fromServer(Server in) {
112         return this.id(in.getId()).hostname(in.getHostname()).datacenter(in.getDatacenter()).platform(in.getPlatform());
113      }
114   }
115 
116   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
117      @Override
118      protected ConcreteBuilder self() {
119         return this;
120      }
121   }
122 
123   private final String id;
124   private final String hostname;
125   private final String datacenter;
126   private final String platform;
127 
128   @ConstructorProperties({
129         "serverid", "hostname", "datacenter", "platform"
130   })
131   protected Server(String id, String hostname, String datacenter, String platform) {
132      this.id = checkNotNull(id, "id");
133      this.hostname = checkNotNull(hostname, "hostname");
134      this.datacenter = checkNotNull(datacenter, "datacenter");
135      this.platform = checkNotNull(platform, "platform");
136   }
137 
138   /**
139    * @return the generated id of the server
140    */
141   public String getId() {
142      return this.id;
143   }
144 
145   /**
146    * @return the hostname of the server
147    */
148   public String getHostname() {
149      return this.hostname;
150   }
151 
152   /**
153    * @return platform running the server (ex. {@code OpenVZ})
154    */
155   public String getDatacenter() {
156      return this.datacenter;
157   }
158 
159   /**
160    * @return the datacenter the server exists in (ex. {@code Falkenberg})
161    */
162   public String getPlatform() {
163      return this.platform;
164   }
165 
166   @Override
167   public int hashCode() {
168      return Objects.hashCode(id);
169   }
170 
171   @Override
172   public boolean equals(Object obj) {
173      if (this == obj) return true;
174      if (obj == null || getClass() != obj.getClass()) return false;
175      Server that = Server.class.cast(obj);
176      return Objects.equal(this.id, that.id);
177   }
178 
179   protected ToStringHelper string() {
180      return Objects.toStringHelper("").add("id", id).add("hostname", hostname).add("datacenter", datacenter)
181            .add("platform", platform);
182   }
183 
184   @Override
185   public String toString() {
186      return string().toString();
187   }
188 
189}

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