EMMA Coverage Report (generated Mon Oct 17 05:41:20 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 * 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.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