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

COVERAGE SUMMARY FOR SOURCE FILE [OrgNameToTasksListEndpoint.java]

nameclass, %method, %block, %line, %
OrgNameToTasksListEndpoint.java0%   (0/1)0%   (0/2)0%   (0/44)0%   (0/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OrgNameToTasksListEndpoint0%   (0/1)0%   (0/2)0%   (0/44)0%   (0/10)
OrgNameToTasksListEndpoint (Supplier, URI): void 0%   (0/1)0%   (0/9)0%   (0/4)
apply (Object): URI 0%   (0/1)0%   (0/35)0%   (0/6)

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.vcloud.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.net.URI;
24import java.util.Map;
25import java.util.NoSuchElementException;
26 
27import javax.inject.Inject;
28import javax.inject.Singleton;
29 
30import org.jclouds.vcloud.domain.Org;
31import org.jclouds.vcloud.endpoints.TasksList;
32 
33import com.google.common.base.Function;
34import com.google.common.base.Supplier;
35 
36/**
37 * 
38 * @author Adrian Cole
39 */
40@Singleton
41public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
42   private final Supplier<Map<String, ? extends Org>> orgMap;
43   private final URI defaultUri;
44 
45   @Inject
46   public OrgNameToTasksListEndpoint(Supplier<Map<String, ? extends Org>> orgMap, @TasksList URI defaultUri) {
47      this.orgMap = orgMap;
48      this.defaultUri = defaultUri;
49   }
50 
51   public URI apply(Object from) {
52      Object org = from;
53      if (org == null)
54         return defaultUri;
55      try {
56         return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
57      } catch (NullPointerException e) {
58         throw new NoSuchElementException(org + " not found in " + orgMap.get());
59      }
60   }
61 
62}

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