EMMA Coverage Report (generated Wed Oct 26 13:47:17 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 (Iterable): 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 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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;
28 
29import org.jclouds.compute.domain.internal.HardwareImpl;
30import org.jclouds.compute.predicates.ImagePredicates;
31import org.jclouds.domain.Location;
32 
33import com.google.common.base.Predicate;
34import com.google.common.collect.ImmutableList;
35import com.google.common.collect.Lists;
36 
37/**
38 * 
39 * @author Adrian Cole
40 */
41public class HardwareBuilder extends ComputeMetadataBuilder {
42   protected List<Processor> processors = Lists.newArrayList();
43   protected int ram;
44   protected List<Volume> volumes = Lists.newArrayList();
45   protected Predicate<Image> supportsImage = any();
46 
47   public HardwareBuilder() {
48      super(ComputeType.HARDWARE);
49   }
50 
51   public HardwareBuilder processor(Processor processor) {
52      this.processors.add(checkNotNull(processor, "processor"));
53      return this;
54   }
55 
56   public HardwareBuilder processors(Iterable<Processor> processors) {
57      this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
58      return this;
59   }
60 
61   public HardwareBuilder ram(int ram) {
62      this.ram = ram;
63      return this;
64   }
65 
66   public HardwareBuilder volume(Volume volume) {
67      this.volumes.add(checkNotNull(volume, "volume"));
68      return this;
69   }
70 
71   public HardwareBuilder volumes(Iterable<Volume> volumes) {
72      this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
73      return this;
74   }
75 
76   public HardwareBuilder supportsImage(Predicate<Image> supportsImage) {
77      this.supportsImage = checkNotNull(supportsImage, "supportsImage");
78      return this;
79   }
80 
81   public HardwareBuilder is64Bit(boolean is64Bit) {
82      supportsImage(is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit()));
83      return this;
84   }
85 
86   @Override
87   public HardwareBuilder id(String id) {
88      return HardwareBuilder.class.cast(super.id(id));
89   }
90   
91   @Override
92   public HardwareBuilder tags(Iterable<String> tags) {
93      return HardwareBuilder.class.cast(super.tags(tags));
94   }
95 
96   @Override
97   public HardwareBuilder ids(String id) {
98      return HardwareBuilder.class.cast(super.ids(id));
99   }
100 
101   @Override
102   public HardwareBuilder providerId(String providerId) {
103      return HardwareBuilder.class.cast(super.providerId(providerId));
104   }
105 
106   @Override
107   public HardwareBuilder name(String name) {
108      return HardwareBuilder.class.cast(super.name(name));
109   }
110 
111   @Override
112   public HardwareBuilder location(Location location) {
113      return HardwareBuilder.class.cast(super.location(location));
114   }
115 
116   @Override
117   public HardwareBuilder uri(URI uri) {
118      return HardwareBuilder.class.cast(super.uri(uri));
119   }
120 
121   @Override
122   public HardwareBuilder userMetadata(Map<String, String> userMetadata) {
123      return HardwareBuilder.class.cast(super.userMetadata(userMetadata));
124   }
125 
126   @Override
127   public Hardware build() {
128      return new HardwareImpl(providerId, name, id, location, uri, userMetadata, tags, processors, ram, volumes,
129               supportsImage);
130   }
131 
132   @SuppressWarnings("unchecked")
133   public static HardwareBuilder fromHardware(Hardware in) {
134      return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name(
135               in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors(
136               List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes()))
137               .supportsImage(in.supportsImage());
138   }
139}

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