EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.compute.domain]

COVERAGE SUMMARY FOR SOURCE FILE [HardwareBuilder.java]

nameclass, %method, %block, %line, %
HardwareBuilder.java100% (1/1)22%  (4/18)27%  (54/198)31%  (9/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HardwareBuilder100% (1/1)22%  (4/18)27%  (54/198)31%  (9/29)
fromHardware (Hardware): HardwareBuilder 0%   (0/1)0%   (0/43)0%   (0/1)
ids (String): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
is64Bit (boolean): HardwareBuilder 0%   (0/1)0%   (0/11)0%   (0/2)
location (Location): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
name (String): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
processor (Processor): HardwareBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
processors (Iterable): HardwareBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
providerId (String): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
ram (int): HardwareBuilder 0%   (0/1)0%   (0/5)0%   (0/2)
tags (Set): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
uri (URI): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
userMetadata (Map): HardwareBuilder 0%   (0/1)0%   (0/7)0%   (0/1)
volume (Volume): HardwareBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
volumes (Iterable): HardwareBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
HardwareBuilder (): void 100% (1/1)100% (13/13)100% (5/5)
build (): Hardware 100% (1/1)100% (26/26)100% (1/1)
id (String): HardwareBuilder 100% (1/1)100% (7/7)100% (1/1)
supportsImage (Predicate): HardwareBuilder 100% (1/1)100% (8/8)100% (2/2)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.compute.domain;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Predicates.not;
23import static org.jclouds.compute.predicates.ImagePredicates.any;
24 
25import java.net.URI;
26import java.util.List;
27import java.util.Map;
28import java.util.Set;
29 
30import org.jclouds.compute.domain.internal.HardwareImpl;
31import org.jclouds.compute.predicates.ImagePredicates;
32import org.jclouds.domain.Location;
33 
34import com.google.common.base.Predicate;
35import com.google.common.collect.ImmutableList;
36import com.google.common.collect.Lists;
37 
38/**
39 * 
40 * @author Adrian Cole
41 */
42public class HardwareBuilder extends ComputeMetadataBuilder {
43   protected List<Processor> processors = Lists.newArrayList();
44   protected int ram;
45   protected List<Volume> volumes = Lists.newArrayList();
46   protected Predicate<Image> supportsImage = any();
47 
48   public HardwareBuilder() {
49      super(ComputeType.HARDWARE);
50   }
51 
52   public HardwareBuilder processor(Processor processor) {
53      this.processors.add(checkNotNull(processor, "processor"));
54      return this;
55   }
56 
57   public HardwareBuilder processors(Iterable<Processor> processors) {
58      this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
59      return this;
60   }
61 
62   public HardwareBuilder ram(int ram) {
63      this.ram = ram;
64      return this;
65   }
66 
67   public HardwareBuilder volume(Volume volume) {
68      this.volumes.add(checkNotNull(volume, "volume"));
69      return this;
70   }
71 
72   public HardwareBuilder volumes(Iterable<Volume> volumes) {
73      this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
74      return this;
75   }
76 
77   public HardwareBuilder supportsImage(Predicate<Image> supportsImage) {
78      this.supportsImage = checkNotNull(supportsImage, "supportsImage");
79      return this;
80   }
81 
82   public HardwareBuilder is64Bit(boolean is64Bit) {
83      supportsImage(is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit()));
84      return this;
85   }
86 
87   @Override
88   public HardwareBuilder id(String id) {
89      return HardwareBuilder.class.cast(super.id(id));
90   }
91   
92   @Override
93   public HardwareBuilder tags(Set<String> tags) {
94      return HardwareBuilder.class.cast(super.tags(tags));
95   }
96 
97   @Override
98   public HardwareBuilder ids(String id) {
99      return HardwareBuilder.class.cast(super.ids(id));
100   }
101 
102   @Override
103   public HardwareBuilder providerId(String providerId) {
104      return HardwareBuilder.class.cast(super.providerId(providerId));
105   }
106 
107   @Override
108   public HardwareBuilder name(String name) {
109      return HardwareBuilder.class.cast(super.name(name));
110   }
111 
112   @Override
113   public HardwareBuilder location(Location location) {
114      return HardwareBuilder.class.cast(super.location(location));
115   }
116 
117   @Override
118   public HardwareBuilder uri(URI uri) {
119      return HardwareBuilder.class.cast(super.uri(uri));
120   }
121 
122   @Override
123   public HardwareBuilder userMetadata(Map<String, String> userMetadata) {
124      return HardwareBuilder.class.cast(super.userMetadata(userMetadata));
125   }
126 
127   @Override
128   public Hardware build() {
129      return new HardwareImpl(providerId, name, id, location, uri, userMetadata, tags, processors, ram, volumes,
130               supportsImage);
131   }
132 
133   @SuppressWarnings("unchecked")
134   public static HardwareBuilder fromHardware(Hardware in) {
135      return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name(
136               in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors(
137               List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes()))
138               .supportsImage(in.supportsImage());
139   }
140}

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