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

COVERAGE SUMMARY FOR SOURCE FILE [Cost.java]

nameclass, %method, %block, %line, %
Cost.java75%  (3/4)74%  (14/19)82%  (145/177)80%  (22.3/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Cost$Builder100% (1/1)83%  (5/6)77%  (37/48)89%  (8/9)
fromCost (Cost): Cost$Builder 0%   (0/1)0%   (0/11)0%   (0/1)
Cost$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
amount (double): Cost$Builder 100% (1/1)100% (6/6)100% (2/2)
build (): Cost 100% (1/1)100% (10/10)100% (1/1)
currency (String): Cost$Builder 100% (1/1)100% (9/9)100% (2/2)
timePeriod (String): Cost$Builder 100% (1/1)100% (9/9)100% (2/2)
     
class Cost100% (1/1)60%  (6/10)83%  (100/121)73%  (12.3/17)
getAmount (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getCurrency (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getTimePeriod (): String 0%   (0/1)0%   (0/3)0%   (0/1)
toBuilder (): Cost$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
equals (Object): boolean 100% (1/1)88%  (38/43)83%  (3.3/4)
Cost (double, String, String): void 100% (1/1)100% (18/18)100% (5/5)
builder (): Cost$Builder 100% (1/1)100% (5/5)100% (1/1)
hashCode (): int 100% (1/1)100% (20/20)100% (1/1)
string (): Objects$ToStringHelper 100% (1/1)100% (15/15)100% (1/1)
toString (): String 100% (1/1)100% (4/4)100% (1/1)
     
class Cost$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class Cost$ConcreteBuilder100% (1/1)100% (3/3)100% (8/8)100% (2/2)
Cost$ConcreteBuilder (): void 100% (1/1)100% (3/3)100% (1/1)
Cost$ConcreteBuilder (Cost$1): void 100% (1/1)100% (3/3)100% (1/1)
self (): Cost$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 * The Cost class contains information about the cost of a server
28 *
29 * @author Adam Lowe
30 * @see ServerDetails
31 */
32public class Cost {
33 
34   public static Builder<?> builder() {
35      return new ConcreteBuilder();
36   }
37 
38   public Builder<?> toBuilder() {
39      return new ConcreteBuilder().fromCost(this);
40   }
41 
42   public abstract static class Builder<T extends Builder<T>> {
43      protected abstract T self();
44 
45      protected double amount;
46      protected String currency;
47      protected String timePeriod;
48 
49      /**
50       * @see Cost#getAmount()
51       */
52      public T amount(double amount) {
53         this.amount = amount;
54         return self();
55      }
56 
57      /**
58       * @see Cost#getCurrency()
59       */
60      public T currency(String currency) {
61         this.currency = checkNotNull(currency, "currency");
62         return self();
63      }
64 
65      /**
66       * @see Cost#getTimePeriod()
67       */
68      public T timePeriod(String timePeriod) {
69         this.timePeriod = checkNotNull(timePeriod, "timePeriod");
70         return self();
71      }
72 
73      public Cost build() {
74         return new Cost(amount, currency, timePeriod);
75      }
76 
77      public T fromCost(Cost in) {
78         return this.amount(in.getAmount()).currency(in.getCurrency()).timePeriod(in.getTimePeriod());
79      }
80   }
81 
82   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
83      @Override
84      protected ConcreteBuilder self() {
85         return this;
86      }
87   }
88 
89   private final double amount;
90   private final String currency;
91   private final String timePeriod;
92 
93   @ConstructorProperties({
94         "amount", "currency", "timeperiod"
95   })
96   protected Cost(double amount, String currency, String timePeriod) {
97      this.amount = amount;
98      this.currency = checkNotNull(currency, "currency");
99      this.timePeriod = checkNotNull(timePeriod, "timePeriod");
100   }
101 
102   /**
103    * @return the numeric cost in #currency / #timePeriod
104    */
105   public double getAmount() {
106      return this.amount;
107   }
108 
109   /**
110    * @return the currency unit, e.g. "EUR" for Euro
111    */
112   public String getCurrency() {
113      return this.currency;
114   }
115 
116   /**
117    * @return the time period for which this cost charged, e.g. "month"
118    */
119   public String getTimePeriod() {
120      return this.timePeriod;
121   }
122 
123   @Override
124   public int hashCode() {
125      return Objects.hashCode(amount, currency, timePeriod);
126   }
127 
128   @Override
129   public boolean equals(Object obj) {
130      if (this == obj) return true;
131      if (obj == null || getClass() != obj.getClass()) return false;
132      Cost that = Cost.class.cast(obj);
133      return Objects.equal(this.amount, that.amount)
134            && Objects.equal(this.currency, that.currency)
135            && Objects.equal(this.timePeriod, that.timePeriod);
136   }
137 
138   protected ToStringHelper string() {
139      return Objects.toStringHelper("")
140            .add("amount", amount).add("currency", currency).add("timePeriod", timePeriod);
141   }
142 
143   @Override
144   public String toString() {
145      return string().toString();
146   }
147}

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