EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.elasticstack.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 *
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.elasticstack.functions;
20 
21import java.util.List;
22import java.util.Map;
23 
24import javax.inject.Singleton;
25 
26import org.jclouds.elasticstack.domain.Model;
27import org.jclouds.elasticstack.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.elasticstack.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov