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

COVERAGE SUMMARY FOR SOURCE FILE [ConvertLB.java]

nameclass, %method, %block, %line, %
ConvertLB.java100% (1/1)100% (2/2)100% (110/110)100% (15/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConvertLB100% (1/1)100% (2/2)100% (110/110)100% (15/15)
ConvertLB (String): void 100% (1/1)100% (7/7)100% (3/3)
apply (LB): LoadBalancer 100% (1/1)100% (103/103)100% (12/12)

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.cloudloadbalancers.functions;
20 
21import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
22import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Builder;
23 
24import com.google.common.base.Function;
25import com.google.common.collect.Iterables;
26 
27/**
28 * @author Adrian Cole
29 */
30public class ConvertLB implements Function<LB, LoadBalancer> {
31 
32   private final String region;
33 
34   ConvertLB(String region) {
35      this.region = region.toUpperCase();
36   }
37 
38   @Override
39   public LoadBalancer apply(LB lb) {
40      Builder builder = LoadBalancer.builder().region(region).name(lb.getName()).port(lb.getPort()).protocol(
41               lb.getProtocol()).algorithm(lb.getAlgorithm()).nodes(lb.getNodes()).id(lb.id).status(lb.status)
42               .virtualIPs(lb.virtualIps);
43      if (lb.cluster.size() == 1)
44         builder.clusterName(Iterables.get(lb.cluster.values(), 0));
45      if (lb.sessionPersistence.size() == 1)
46         builder.sessionPersistenceType(Iterables.get(lb.sessionPersistence.values(), 0));
47      if (lb.created.size() == 1)
48         builder.created(Iterables.get(lb.created.values(), 0));
49      if (lb.updated.size() == 1)
50         builder.updated(Iterables.get(lb.updated.values(), 0));
51      if (lb.connectionLogging.size() == 1)
52         builder.connectionLoggingEnabled(Iterables.get(lb.connectionLogging.values(), 0));
53      return builder.build();
54   }
55 
56}

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