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

COVERAGE SUMMARY FOR SOURCE FILE [MapToNICs.java]

nameclass, %method, %block, %line, %
MapToNICs.java100% (1/1)100% (2/2)100% (149/149)100% (15/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MapToNICs100% (1/1)100% (2/2)100% (149/149)100% (15/15)
MapToNICs (): void 100% (1/1)100% (3/3)100% (1/1)
apply (Map): List 100% (1/1)100% (146/146)100% (14/14)

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.List;
22import java.util.Map;
23 
24import javax.inject.Singleton;
25 
26import org.jclouds.cloudsigma.domain.Model;
27import org.jclouds.cloudsigma.domain.NIC;
28 
29import com.google.common.base.Function;
30import com.google.common.base.Splitter;
31import com.google.common.collect.ImmutableList;
32 
33/**
34 * 
35 * @author Adrian Cole
36 */
37@Singleton
38public class MapToNICs implements Function<Map<String, String>, List<NIC>> {
39 
40   @Override
41   public List<NIC> apply(Map<String, String> from) {
42      ImmutableList.Builder<NIC> nics = ImmutableList.builder();
43      NIC: for (int id : new int[] { 0, 1 }) {
44         String key = String.format("nic:%d", id);
45         if (!from.containsKey(key + ":model"))
46            break NIC;
47         NIC.Builder nicBuilder = new NIC.Builder();
48         nicBuilder.dhcp(from.get(key + ":dhcp"));
49         nicBuilder.model(Model.fromValue(from.get(key + ":model")));
50         nicBuilder.vlan(from.get(key + ":vlan"));
51         nicBuilder.mac(from.get(key + ":mac"));
52         if (from.containsKey(key + ":block"))
53            nicBuilder.block(Splitter.on(' ').split(from.get(key + ":block")));
54         nics.add(nicBuilder.build());
55      }
56      return nics.build();
57   }
58}

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