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

COVERAGE SUMMARY FOR SOURCE FILE [ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java]

nameclass, %method, %block, %line, %
ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java100% (1/1)100% (2/2)100% (35/35)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet100% (1/1)100% (2/2)100% (35/35)100% (9/9)
ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet (ReturnStringIf2xx, ListO... 100% (1/1)100% (12/12)100% (5/5)
apply (HttpResponse): Set 100% (1/1)100% (23/23)100% (4/4)

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.cloudsigma.functions;
20 
21import java.util.Set;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.cloudsigma.domain.ServerInfo;
27import org.jclouds.http.HttpResponse;
28import org.jclouds.http.functions.ReturnStringIf2xx;
29 
30import com.google.common.base.Function;
31import com.google.common.collect.ImmutableSet;
32import com.google.common.collect.Iterables;
33 
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39@Singleton
40public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet implements Function<HttpResponse, Set<ServerInfo>> {
41   private final ReturnStringIf2xx returnStringIf200;
42   private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter;
43   private final MapToServerInfo mapToServer;
44 
45   @Inject
46   ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet(ReturnStringIf2xx returnStringIf200,
47         ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToServerInfo mapToServer) {
48      this.returnStringIf200 = returnStringIf200;
49      this.mapConverter = mapConverter;
50      this.mapToServer = mapToServer;
51   }
52 
53   @Override
54   public Set<ServerInfo> apply(HttpResponse response) {
55      String text = returnStringIf200.apply(response);
56      if (text == null || text.trim().equals(""))
57         return ImmutableSet.<ServerInfo> of();
58      return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToServer));
59   }
60}

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