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

COVERAGE SUMMARY FOR SOURCE FILE [Ip.java]

nameclass, %method, %block, %line, %
Ip.java75%  (3/4)65%  (15/23)51%  (106/209)68%  (23/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Ip100% (1/1)45%  (5/11)37%  (52/140)53%  (10/19)
equals (Object): boolean 0%   (0/1)0%   (0/51)0%   (0/4)
getCost (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getCurrency (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getVersion (): int 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/21)0%   (0/1)
toBuilder (): Ip$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
Ip (String, int, double, String): void 100% (1/1)100% (21/21)100% (6/6)
builder (): Ip$Builder 100% (1/1)100% (5/5)100% (1/1)
getIp (): 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 Ip$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class Ip$Builder100% (1/1)78%  (7/9)75%  (46/61)85%  (11/13)
fromIp (Ip): Ip$Builder 0%   (0/1)0%   (0/11)0%   (0/1)
version6 (): Ip$Builder 0%   (0/1)0%   (0/4)0%   (0/1)
Ip$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): Ip 100% (1/1)100% (12/12)100% (1/1)
cost (double): Ip$Builder 100% (1/1)100% (6/6)100% (2/2)
currency (String): Ip$Builder 100% (1/1)100% (6/6)100% (2/2)
ip (String): Ip$Builder 100% (1/1)100% (9/9)100% (2/2)
version (int): Ip$Builder 100% (1/1)100% (6/6)100% (2/2)
version4 (): Ip$Builder 100% (1/1)100% (4/4)100% (1/1)
     
class Ip$ConcreteBuilder100% (1/1)100% (3/3)100% (8/8)100% (2/2)
Ip$ConcreteBuilder (): void 100% (1/1)100% (3/3)100% (1/1)
Ip$ConcreteBuilder (Ip$1): void 100% (1/1)100% (3/3)100% (1/1)
self (): Ip$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 * Represents an ip address used by a server.
28 *
29 * @author Adam Lowe
30 * @see Server
31 * @see ServerDetails
32 */
33public class Ip {
34 
35   public static Builder<?> builder() {
36      return new ConcreteBuilder();
37   }
38 
39   public Builder<?> toBuilder() {
40      return new ConcreteBuilder().fromIp(this);
41   }
42 
43   public abstract static class Builder<T extends Builder<T>> {
44      protected abstract T self();
45 
46      protected String ip;
47      protected int version;
48      protected double cost;
49      protected String currency;
50 
51      /**
52       * @see Ip#getIp()
53       */
54      public T ip(String ip) {
55         this.ip = checkNotNull(ip, "ip");
56         return self();
57      }
58 
59      /**
60       * @see Ip#getVersion()
61       */
62      protected T version(int version) {
63         this.version = version;
64         return self();
65      }
66 
67      /**
68       * @see Ip#getVersion()
69       */
70      public T version4() {
71         return version(4);
72      }
73 
74      /**
75       * @see Ip#getVersion()
76       */
77      public T version6() {
78         return version(6);
79      }
80 
81      /**
82       * @see Ip#getCost()
83       */
84      public T cost(double cost) {
85         this.cost = cost;
86         return self();
87      }
88 
89      /**
90       * @see Ip#getCurrency()
91       */
92      public T currency(String currency) {
93         this.currency = currency;
94         return self();
95      }
96 
97      public Ip build() {
98         return new Ip(ip, version, cost, currency);
99      }
100 
101      public T fromIp(Ip in) {
102         return this.ip(in.getIp()).version(in.getVersion()).cost(in.getCost());
103      }
104   }
105 
106   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
107      @Override
108      protected ConcreteBuilder self() {
109         return this;
110      }
111   }
112 
113   private final String ip;
114   private final int version;
115   private final double cost;
116   private final String currency;
117 
118   @ConstructorProperties({
119         "ipaddress", "version", "cost", "currency"
120   })
121   protected Ip(String ip, int version, double cost, String currency) {
122      this.ip = checkNotNull(ip, "ip");
123      this.version = version;
124      this.cost = cost;
125      this.currency = checkNotNull(currency, "currency");
126   }
127 
128   /**
129    * @return the IP version, ex. 4
130    */
131   public String getIp() {
132      return this.ip;
133   }
134 
135   /**
136    * @return the ip address of the new server
137    */
138   public int getVersion() {
139      return this.version;
140   }
141 
142   /**
143    * @return the cost of the ip address allocated to the new server
144    * @see #getCurrency()
145    */
146   public double getCost() {
147      return this.cost;
148   }
149 
150   /**
151    * @return the currency of the cost
152    * @see #getCost() 
153    */
154   public String getCurrency() {
155      return currency;
156   }
157 
158   @Override
159   public int hashCode() {
160      return Objects.hashCode(ip, version, cost);
161   }
162 
163   @Override
164   public boolean equals(Object obj) {
165      if (this == obj) return true;
166      if (obj == null || getClass() != obj.getClass()) return false;
167      Ip that = Ip.class.cast(obj);
168      return Objects.equal(this.ip, that.ip)
169            && Objects.equal(this.version, that.version)
170            && Objects.equal(this.cost, that.cost)
171            && Objects.equal(this.currency, that.currency);
172   }
173 
174   protected ToStringHelper string() {
175      return Objects.toStringHelper("")
176            .add("ip", ip).add("version", version).add("cost", cost).add("currency", currency);
177   }
178 
179   @Override
180   public String toString() {
181      return string().toString();
182   }
183 
184}

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