EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.compute.domain.internal]

COVERAGE SUMMARY FOR SOURCE FILE [HardwareImpl.java]

nameclass, %method, %block, %line, %
HardwareImpl.java100% (1/1)57%  (4/7)33%  (40/120)60%  (9/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HardwareImpl100% (1/1)57%  (4/7)33%  (40/120)60%  (9/15)
compareTo (ResourceMetadata): int 0%   (0/1)0%   (0/30)0%   (0/4)
getVolumes (): List 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/47)0%   (0/1)
HardwareImpl (String, String, String, Location, URI, Map, Set, Iterable, int,... 100% (1/1)100% (31/31)100% (6/6)
getProcessors (): List 100% (1/1)100% (3/3)100% (1/1)
getRam (): int 100% (1/1)100% (3/3)100% (1/1)
supportsImage (): Predicate 100% (1/1)100% (3/3)100% (1/1)

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.internal;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.compute.util.ComputeServiceUtils.getCoresAndSpeed;
23import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
24 
25import java.net.URI;
26import java.util.List;
27import java.util.Map;
28import java.util.Set;
29 
30import org.jclouds.javax.annotation.Nullable;
31 
32import org.jclouds.compute.domain.ComputeType;
33import org.jclouds.compute.domain.Hardware;
34import org.jclouds.compute.domain.Image;
35import org.jclouds.compute.domain.Processor;
36import org.jclouds.compute.domain.Volume;
37import org.jclouds.domain.Location;
38import org.jclouds.domain.ResourceMetadata;
39 
40import com.google.common.base.Predicate;
41import com.google.common.collect.ComparisonChain;
42import com.google.common.collect.ImmutableList;
43 
44/**
45 * @author Adrian Cole
46 */
47public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
48 
49   /** The serialVersionUID */
50   private static final long serialVersionUID = 8994255275911717567L;
51   private final List<Processor> processors;
52   private final int ram;
53   private final List<Volume> volumes;
54   private final Predicate<Image> supportsImage;
55 
56   public HardwareImpl(String providerId, String name, String id, @Nullable Location location, URI uri,
57         Map<String, String> userMetadata, Set<String> tags, Iterable<? extends Processor> processors, int ram,
58         Iterable<? extends Volume> volumes, Predicate<Image> supportsImage) {
59      super(ComputeType.HARDWARE, providerId, name, id, location, uri, userMetadata, tags);
60      this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
61      this.ram = ram;
62      this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
63      this.supportsImage = supportsImage;
64   }
65 
66   /**
67    * {@inheritDoc}
68    */
69   @Override
70   public List<? extends Processor> getProcessors() {
71      return processors;
72   }
73 
74   /**
75    * {@inheritDoc}
76    */
77   @Override
78   public int getRam() {
79      return ram;
80   }
81 
82   /**
83    * {@inheritDoc}
84    */
85   @Override
86   public List<? extends Volume> getVolumes() {
87      return volumes;
88   }
89 
90   /**
91    * {@inheritDoc}
92    */
93   @Override
94   public int compareTo(ResourceMetadata<ComputeType> that) {
95      if (that instanceof Hardware) {
96         Hardware thatHardware = Hardware.class.cast(that);
97         return ComparisonChain.start().compare(getCoresAndSpeed(this), getCoresAndSpeed(thatHardware))
98               .compare(this.getRam(), thatHardware.getRam()).compare(getSpace(this), getSpace(thatHardware)).result();
99      } else {
100         return super.compareTo(that);
101      }
102   }
103 
104   /**
105    * {@inheritDoc}
106    */
107   @Override
108   public String toString() {
109      return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName() + ", processors="
110            + processors + ", ram=" + ram + ", volumes=" + volumes + ", supportsImage=" + supportsImage + ", tags=" + tags + "]";
111   }
112 
113   /**
114    * {@inheritDoc}
115    */
116   @Override
117   public Predicate<Image> supportsImage() {
118      return supportsImage;
119   }
120 
121}

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