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

COVERAGE SUMMARY FOR SOURCE FILE [SplitNewlinesAndReturnSecondField.java]

nameclass, %method, %block, %line, %
SplitNewlinesAndReturnSecondField.java50%  (1/2)25%  (1/4)8%   (4/51)17%  (2/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SplitNewlinesAndReturnSecondField$10%   (0/1)0%   (0/2)0%   (0/35)0%   (0/9)
SplitNewlinesAndReturnSecondField$1 (SplitNewlinesAndReturnSecondField): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (String): String 0%   (0/1)0%   (0/29)0%   (0/8)
     
class SplitNewlinesAndReturnSecondField100% (1/1)50%  (1/2)25%  (4/16)67%  (2/3)
apply (HttpResponse): Set 0%   (0/1)0%   (0/12)0%   (0/1)
SplitNewlinesAndReturnSecondField (ReturnStringIf2xx): void 100% (1/1)100% (4/4)100% (2/2)

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.cloudsigma.functions;
20 
21import java.util.Set;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.http.HttpResponse;
27import org.jclouds.http.functions.ReturnStringIf2xx;
28 
29import com.google.common.base.Function;
30import com.google.common.base.Predicates;
31import com.google.common.base.Splitter;
32import com.google.common.collect.ImmutableSet;
33import com.google.common.collect.Iterables;
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39@Singleton
40public class SplitNewlinesAndReturnSecondField extends SplitNewlines {
41 
42   @Inject
43   SplitNewlinesAndReturnSecondField(ReturnStringIf2xx returnStringIf200) {
44      super(returnStringIf200);
45   }
46 
47   @Override
48   public Set<String> apply(HttpResponse response) {
49      return ImmutableSet.copyOf(Iterables.filter(
50            Iterables.transform(super.apply(response), new Function<String, String>() {
51 
52               @Override
53               public String apply(String arg0) {
54                  if (arg0 == null)
55                     return null;
56                  Iterable<String> parts = Splitter.on(' ').split(arg0);
57                  if (Iterables.size(parts) == 2)
58                     return Iterables.get(parts, 1);
59                  else if (Iterables.size(parts) == 1)
60                     return Iterables.get(parts, 0);
61                  return null;
62               }
63 
64            }), Predicates.notNull()));
65   }
66}

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