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