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

COVERAGE SUMMARY FOR SOURCE FILE [BaseDriveToMap.java]

nameclass, %method, %block, %line, %
BaseDriveToMap.java100% (1/1)100% (2/2)100% (96/96)100% (14/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BaseDriveToMap100% (1/1)100% (2/2)100% (96/96)100% (14/14)
BaseDriveToMap (): void 100% (1/1)100% (3/3)100% (1/1)
apply (Drive): Map 100% (1/1)100% (93/93)100% (13/13)

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 static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Map;
24import java.util.Map.Entry;
25 
26import javax.inject.Singleton;
27 
28import org.jclouds.elasticstack.domain.Drive;
29import org.jclouds.elasticstack.domain.ClaimType;
30 
31import com.google.common.base.Function;
32import com.google.common.base.Joiner;
33import com.google.common.collect.ImmutableMap;
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39@Singleton
40public class BaseDriveToMap implements Function<Drive, Map<String, String>> {
41   @Override
42   public Map<String, String> apply(Drive from) {
43      checkNotNull(from, "drive");
44      ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
45      builder.put("name", from.getName());
46      builder.put("size", from.getSize() + "");
47      if (from.getClaimType() != ClaimType.EXCLUSIVE)
48         builder.put("claim:type", from.getClaimType().toString());
49      if (from.getReaders().size() != 0)
50         builder.put("readers", Joiner.on(' ').join(from.getReaders()));
51      if (from.getTags().size() != 0)
52         builder.put("tags", Joiner.on(' ').join(from.getTags()));
53      for (Entry<String, String> entry : from.getUserMetadata().entrySet())
54         builder.put("user:" + entry.getKey(), entry.getValue());
55      return builder.build();
56   }
57}

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