EMMA Coverage Report (generated Tue Jun 21 05:51:52 EDT 2011)
[all classes][org.jclouds.compute.predicates]

COVERAGE SUMMARY FOR SOURCE FILE [ImagePredicates.java]

nameclass, %method, %block, %line, %
ImagePredicates.java50%  (2/4)31%  (5/16)37%  (35/94)31%  (5/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ImagePredicates$10%   (0/1)0%   (0/3)0%   (0/24)0%   (0/3)
ImagePredicates$1 (Set): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Image): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/12)0%   (0/1)
     
class ImagePredicates$Is64BitPredicate0%   (0/1)0%   (0/5)0%   (0/15)0%   (0/4)
ImagePredicates$Is64BitPredicate (): void 0%   (0/1)0%   (0/3)0%   (0/1)
ImagePredicates$Is64BitPredicate (ImagePredicates$1): void 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Image): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/2)0%   (0/1)
     
class ImagePredicates100% (1/1)40%  (2/5)35%  (11/31)33%  (3/9)
ImagePredicates (): void 0%   (0/1)0%   (0/3)0%   (0/2)
idIn (Iterable): Predicate 0%   (0/1)0%   (0/12)0%   (0/3)
is64Bit (): Predicate 0%   (0/1)0%   (0/5)0%   (0/1)
any (): Predicate 100% (1/1)100% (2/2)100% (1/1)
idEquals (String): Predicate 100% (1/1)100% (9/9)100% (2/2)
     
class ImagePredicates$2100% (1/1)100% (3/3)100% (24/24)100% (3/3)
ImagePredicates$2 (String): void 100% (1/1)100% (6/6)100% (1/1)
apply (Image): boolean 100% (1/1)100% (6/6)100% (1/1)
toString (): String 100% (1/1)100% (12/12)100% (1/1)

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.predicates;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Set;
24 
25import javax.annotation.Nullable;
26 
27import org.jclouds.compute.domain.Image;
28 
29import com.google.common.base.Predicate;
30import com.google.common.base.Predicates;
31import com.google.common.collect.Sets;
32 
33/**
34 * Container for image filters (predicates).
35 * 
36 * This class has static methods that create customized predicates to use with
37 * {@link org.jclouds.compute.ComputeService}.
38 * 
39 * @author Adrian Cole
40 */
41public class ImagePredicates {
42   private static final class Is64BitPredicate implements Predicate<Image> {
43      @Override
44      public boolean apply(Image image) {
45         return image.getOperatingSystem().is64Bit();
46      }
47 
48      @Override
49      public String toString() {
50         return "is64Bit()";
51      }
52 
53      @Override
54      public boolean equals(@Nullable Object obj) {
55         return (obj instanceof Is64BitPredicate);
56      }
57 
58   }
59 
60   /**
61    * evaluates true if the Image
62    * 
63    * @param ids
64    *           ids of the images
65    * @return predicate
66    */
67   public static Predicate<Image> idIn(Iterable<String> ids) {
68      checkNotNull(ids, "ids must be defined");
69      final Set<String> search = Sets.newHashSet(ids);
70      return new Predicate<Image>() {
71         @Override
72         public boolean apply(Image image) {
73            return search.contains(image.getId());
74         }
75 
76         @Override
77         public String toString() {
78            return "idIn(" + search + ")";
79         }
80      };
81   }
82 
83   /**
84    * evaluates true if the Image
85    * 
86    * @param ids
87    *           ids of the images
88    * @return predicate
89    */
90   public static Predicate<Image> idEquals(final String id) {
91      checkNotNull(id, "id must be defined");
92      return new Predicate<Image>() {
93         @Override
94         public boolean apply(Image image) {
95            return id.equals(image.getId());
96         }
97 
98         @Override
99         public String toString() {
100            return "idEquals(" + id + ")";
101         }
102      };
103   }
104 
105   /**
106    * return true if this is a 64bit image.
107    */
108   public static Predicate<Image> is64Bit() {
109      return new Is64BitPredicate();
110   }
111 
112   /**
113    * return everything.
114    */
115   public static Predicate<Image> any() {
116      return Predicates.<Image> alwaysTrue();
117   }
118 
119}

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