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

COVERAGE SUMMARY FOR SOURCE FILE [AllowedArguments.java]

nameclass, %method, %block, %line, %
AllowedArguments.java100% (2/2)67%  (10/15)71%  (95/134)72%  (18/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllowedArguments100% (1/1)56%  (5/9)68%  (65/96)64%  (11/17)
getAllowedUnits (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getCostPerUnit (): Cost 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/14)0%   (0/1)
toBuilder (): AllowedArguments$Builder 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 100% (1/1)86%  (30/35)66%  (4/6)
AllowedArguments (Cost, Set): void 100% (1/1)100% (16/16)100% (4/4)
builder (): AllowedArguments$Builder 100% (1/1)100% (4/4)100% (1/1)
string (): Objects$ToStringHelper 100% (1/1)100% (11/11)100% (1/1)
toString (): String 100% (1/1)100% (4/4)100% (1/1)
     
class AllowedArguments$Builder100% (1/1)83%  (5/6)79%  (30/38)88%  (7/8)
fromAllowedArgument (AllowedArguments): AllowedArguments$Builder 0%   (0/1)0%   (0/8)0%   (0/1)
AllowedArguments$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
allowedUnits (Integer []): AllowedArguments$Builder 100% (1/1)100% (5/5)100% (1/1)
allowedUnits (Set): AllowedArguments$Builder 100% (1/1)100% (9/9)100% (2/2)
build (): AllowedArguments 100% (1/1)100% (8/8)100% (1/1)
costPerUnit (Cost): AllowedArguments$Builder 100% (1/1)100% (5/5)100% (2/2)

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;
22import java.util.Set;
23 
24import com.google.common.base.Objects;
25import com.google.common.base.Objects.ToStringHelper;
26import com.google.common.collect.ImmutableSet;
27 
28/**
29 * Represents the allowed arguments for a certain server resource type (such as
30 * disksize, memorysize, cpucores, and transfer).
31 * <p/>
32 * This is a composite type consisting of both the set of allowed units for the
33 * resource type as well as the cost per unit.
34 * 
35 * @see AllowedArgumentsForCreateServer
36 * @author Peter Gardfjäll
37 */
38public class AllowedArguments {
39        public static Builder builder() {
40                return new Builder();
41        }
42 
43        public Builder toBuilder() {
44                return new Builder().fromAllowedArgument(this);
45        }
46 
47        public static class Builder {
48 
49                protected Cost costPerUnit;
50                protected Set<Integer> allowedUnits;
51 
52                /**
53                 * @see AllowedArguments#getCostPerUnit()
54                 */
55                public Builder costPerUnit(Cost costPerUnit) {
56                        this.costPerUnit = costPerUnit;
57                        return this;
58                }
59 
60                /**
61                 * @see AllowedArguments#getAllowedUnits()
62                 */
63                public Builder allowedUnits(Set<Integer> allowedUnits) {
64                        this.allowedUnits = ImmutableSet.copyOf(checkNotNull(allowedUnits,
65                                        "allowedUnits"));
66                        return this;
67                }
68 
69                public Builder allowedUnits(Integer... allowedUnits) {
70                        return allowedUnits(ImmutableSet.copyOf(allowedUnits));
71                }
72 
73                public AllowedArguments build() {
74                        return new AllowedArguments(this.costPerUnit, this.allowedUnits);
75                }
76 
77                public Builder fromAllowedArgument(AllowedArguments in) {
78                        return this.costPerUnit(in.getCostPerUnit()).allowedUnits(
79                                        in.getAllowedUnits());
80                }
81        }
82 
83        private final Cost costPerUnit;
84        private final Set<Integer> allowedUnits;
85 
86        @ConstructorProperties({ "costperunit", "units" })
87        protected AllowedArguments(Cost costPerUnit, Set<Integer> units) {
88                this.costPerUnit = checkNotNull(costPerUnit, "costPerUnit");
89                this.allowedUnits = ImmutableSet.copyOf(checkNotNull(units,
90                                "allowedUnits"));
91        }
92 
93        /**
94         * @return the cost per unit.
95         */
96        public Cost getCostPerUnit() {
97                return this.costPerUnit;
98        }
99 
100        /**
101         * @return the set of allowed units for the resource type.
102         */
103        public Set<Integer> getAllowedUnits() {
104                return this.allowedUnits;
105        }
106 
107        @Override
108        public int hashCode() {
109                return Objects.hashCode(this.costPerUnit, this.allowedUnits);
110        }
111 
112        @Override
113        public boolean equals(Object obj) {
114                if (this == obj) {
115                        return true;
116                }
117                if ((obj == null) || (getClass() != obj.getClass())) {
118                        return false;
119                }
120                AllowedArguments that = AllowedArguments.class.cast(obj);
121                return Objects.equal(this.costPerUnit, that.costPerUnit)
122                                && Objects.equal(this.allowedUnits, that.allowedUnits);
123        }
124 
125        protected ToStringHelper string() {
126                return Objects.toStringHelper("").add("costPerUnit", this.costPerUnit)
127                                .add("allowedUnits", this.allowedUnits);
128        }
129 
130        @Override
131        public String toString() {
132                return string().toString();
133        }
134}

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