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

COVERAGE SUMMARY FOR SOURCE FILE [ResourceStatus.java]

nameclass, %method, %block, %line, %
ResourceStatus.java75%  (3/4)58%  (11/19)59%  (102/174)69%  (19.3/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceStatus100% (1/1)30%  (3/10)50%  (60/121)55%  (9.3/17)
getMax (): double 0%   (0/1)0%   (0/3)0%   (0/1)
getUnit (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getUsage (): double 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/21)0%   (0/1)
string (): Objects$ToStringHelper 0%   (0/1)0%   (0/15)0%   (0/1)
toBuilder (): ResourceStatus$Builder 0%   (0/1)0%   (0/7)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/4)0%   (0/1)
equals (Object): boolean 100% (1/1)89%  (40/45)83%  (3.3/4)
ResourceStatus (double, double, String): void 100% (1/1)100% (15/15)100% (5/5)
builder (): ResourceStatus$Builder 100% (1/1)100% (5/5)100% (1/1)
     
class ResourceStatus$10%   (0/1)100% (0/0)100% (0/0)100% (0/0)
     
class ResourceStatus$Builder100% (1/1)83%  (5/6)76%  (34/45)89%  (8/9)
fromResourceUsage (ResourceStatus): ResourceStatus$Builder 0%   (0/1)0%   (0/11)0%   (0/1)
ResourceStatus$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): ResourceStatus 100% (1/1)100% (10/10)100% (1/1)
max (double): ResourceStatus$Builder 100% (1/1)100% (6/6)100% (2/2)
unit (String): ResourceStatus$Builder 100% (1/1)100% (9/9)100% (2/2)
usage (double): ResourceStatus$Builder 100% (1/1)100% (6/6)100% (2/2)
     
class ResourceStatus$ConcreteBuilder100% (1/1)100% (3/3)100% (8/8)100% (2/2)
ResourceStatus$ConcreteBuilder (): void 100% (1/1)100% (3/3)100% (1/1)
ResourceStatus$ConcreteBuilder (ResourceStatus$1): void 100% (1/1)100% (3/3)100% (1/1)
self (): ResourceStatus$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 * Detailed information on usage
28 *
29 * @author Adam Lowe
30 * @see ServerStatus
31 */
32public class ResourceStatus {
33 
34   public static Builder<?> builder() {
35      return new ConcreteBuilder();
36   }
37 
38   public Builder<?> toBuilder() {
39      return new ConcreteBuilder().fromResourceUsage(this);
40   }
41 
42   public abstract static class Builder<T extends Builder<T>> {
43      protected abstract T self();
44 
45      protected double usage;
46      protected double max;
47      protected String unit;
48 
49      /**
50       * @see ResourceStatus#getUsage()
51       */
52      public T usage(double usage) {
53         this.usage = usage;
54         return self();
55      }
56 
57      /**
58       * @see ResourceStatus#getMax()
59       */
60      public T max(double max) {
61         this.max = max;
62         return self();
63      }
64 
65      /**
66       * @see ResourceStatus#getUnit()
67       */
68      public T unit(String unit) {
69         this.unit = checkNotNull(unit, "unit");
70         return self();
71      }
72 
73      public ResourceStatus build() {
74         return new ResourceStatus(usage, max, unit);
75      }
76 
77      public T fromResourceUsage(ResourceStatus in) {
78         return this.usage(in.getUsage()).max(in.getMax()).unit(in.getUnit());
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 usage;
90   private final double max;
91   private final String unit;
92 
93   @ConstructorProperties({
94         "usage", "max", "unit"
95   })
96   protected ResourceStatus(double usage, double max, String unit) {
97      this.usage = usage;
98      this.max = max;
99      this.unit = checkNotNull(unit, "unit");
100   }
101 
102   /**
103    * @return the usage in #unit
104    */
105   public double getUsage() {
106      return this.usage;
107   }
108 
109   /**
110    * @return the max usage in #unit
111    */
112   public double getMax() {
113      return this.max;
114   }
115 
116   /**
117    * @return the unit used
118    */
119   public String getUnit() {
120      return this.unit;
121   }
122 
123   @Override
124   public int hashCode() {
125      return Objects.hashCode(usage, max, unit);
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      ResourceStatus that = ResourceStatus.class.cast(obj);
133      return Objects.equal(this.usage, that.usage)
134            && Objects.equal(this.max, that.max)
135            && Objects.equal(this.unit, that.unit);
136   }
137 
138   protected ToStringHelper string() {
139      return Objects.toStringHelper("").add("usage", usage).add("max", max).add("unit", unit);
140   }
141 
142   @Override
143   public String toString() {
144      return string().toString();
145   }
146 
147}

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