EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.vcloud.functions]

COVERAGE SUMMARY FOR SOURCE FILE [AllCatalogItemsInCatalog.java]

nameclass, %method, %block, %line, %
AllCatalogItemsInCatalog.java0%   (0/3)0%   (0/7)0%   (0/68)0%   (0/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AllCatalogItemsInCatalog0%   (0/1)0%   (0/3)0%   (0/44)0%   (0/8)
AllCatalogItemsInCatalog (VCloudAsyncClient, ExecutorService): void 0%   (0/1)0%   (0/12)0%   (0/5)
access$000 (AllCatalogItemsInCatalog): VCloudAsyncClient 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Catalog): Iterable 0%   (0/1)0%   (0/29)0%   (0/2)
     
class AllCatalogItemsInCatalog$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
AllCatalogItemsInCatalog$1 (AllCatalogItemsInCatalog): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ReferenceType): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
     
class AllCatalogItemsInCatalog$20%   (0/1)0%   (0/2)0%   (0/13)0%   (0/2)
AllCatalogItemsInCatalog$2 (AllCatalogItemsInCatalog): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (ReferenceType): Future 0%   (0/1)0%   (0/7)0%   (0/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.vcloud.functions;
20 
21import static com.google.common.collect.Iterables.filter;
22import static org.jclouds.concurrent.FutureIterables.transformParallel;
23 
24import java.util.concurrent.ExecutorService;
25import java.util.concurrent.Future;
26 
27import javax.annotation.Resource;
28import javax.inject.Inject;
29import javax.inject.Named;
30import javax.inject.Singleton;
31 
32import org.jclouds.Constants;
33import org.jclouds.logging.Logger;
34import org.jclouds.vcloud.VCloudAsyncClient;
35import org.jclouds.vcloud.VCloudMediaType;
36import org.jclouds.vcloud.domain.Catalog;
37import org.jclouds.vcloud.domain.CatalogItem;
38import org.jclouds.vcloud.domain.ReferenceType;
39 
40import com.google.common.base.Function;
41import com.google.common.base.Predicate;
42 
43/**
44 * @author Adrian Cole
45 */
46@Singleton
47public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<? extends CatalogItem>> {
48   @Resource
49   public Logger logger = Logger.NULL;
50 
51   private final VCloudAsyncClient aclient;
52   private final ExecutorService executor;
53 
54   @Inject
55   AllCatalogItemsInCatalog(VCloudAsyncClient aclient,
56            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
57      this.aclient = aclient;
58      this.executor = executor;
59   }
60 
61   @Override
62   public Iterable<? extends CatalogItem> apply(Catalog from) {
63 
64      Iterable<CatalogItem> catalogItems = transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
65 
66         @Override
67         public boolean apply(ReferenceType input) {
68            return input.getType().equals(VCloudMediaType.CATALOGITEM_XML);
69         }
70 
71      }), new Function<ReferenceType, Future<CatalogItem>>() {
72 
73         @SuppressWarnings("unchecked")
74         @Override
75         public Future<CatalogItem> apply(ReferenceType from) {
76            return (Future<CatalogItem>) aclient.getCatalogItem(from.getHref());
77         }
78 
79      }, executor, null, logger, "catalogItems in " + from.getHref());
80      return catalogItems;
81   }
82 
83}

[all classes][org.jclouds.vcloud.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov