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

COVERAGE SUMMARY FOR SOURCE FILE [DirectoryEntryListToResourceMetadataList.java]

nameclass, %method, %block, %line, %
DirectoryEntryListToResourceMetadataList.java50%  (1/2)20%  (1/5)8%   (6/78)30%  (3/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DirectoryEntryListToResourceMetadataList$10%   (0/1)0%   (0/2)0%   (0/57)0%   (0/5)
DirectoryEntryListToResourceMetadataList$1 (DirectoryEntryListToResourceMetad... 0%   (0/1)0%   (0/6)0%   (0/1)
apply (DirectoryEntry): StorageMetadata 0%   (0/1)0%   (0/51)0%   (0/4)
     
class DirectoryEntryListToResourceMetadataList100% (1/1)33%  (1/3)29%  (6/21)60%  (3/5)
access$000 (DirectoryEntryListToResourceMetadataList): Supplier 0%   (0/1)0%   (0/3)0%   (0/1)
apply (BoundedSet): PageSet 0%   (0/1)0%   (0/12)0%   (0/1)
DirectoryEntryListToResourceMetadataList (Supplier): void 100% (1/1)100% (6/6)100% (3/3)

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.atmos.blobstore.functions;
20 
21import javax.inject.Inject;
22import javax.inject.Singleton;
23 
24import org.jclouds.atmos.domain.BoundedSet;
25import org.jclouds.atmos.domain.DirectoryEntry;
26import org.jclouds.atmos.domain.FileType;
27import org.jclouds.blobstore.domain.PageSet;
28import org.jclouds.blobstore.domain.StorageMetadata;
29import org.jclouds.blobstore.domain.StorageType;
30import org.jclouds.blobstore.domain.internal.BlobMetadataImpl;
31import org.jclouds.blobstore.domain.internal.PageSetImpl;
32import org.jclouds.blobstore.domain.internal.StorageMetadataImpl;
33import org.jclouds.domain.Location;
34import org.jclouds.io.payloads.BaseMutableContentMetadata;
35 
36import com.google.common.base.Function;
37import com.google.common.base.Supplier;
38import com.google.common.collect.ImmutableMap;
39import com.google.common.collect.Iterables;
40 
41/**
42 * @author Adrian Cole
43 */
44@Singleton
45public class DirectoryEntryListToResourceMetadataList implements
46         Function<BoundedSet<? extends DirectoryEntry>, PageSet<? extends StorageMetadata>> {
47   private Supplier<Location> defaultLocation;
48 
49   @Inject
50   DirectoryEntryListToResourceMetadataList(Supplier<Location> defaultLocation) {
51      this.defaultLocation = defaultLocation;
52   }
53 
54   public PageSet<? extends StorageMetadata> apply(BoundedSet<? extends DirectoryEntry> from) {
55 
56      return new PageSetImpl<StorageMetadata>(Iterables.transform(from,
57               new Function<DirectoryEntry, StorageMetadata>() {
58 
59                  public StorageMetadata apply(DirectoryEntry from) {
60                     StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB;
61                     if (type == StorageType.FOLDER)
62                        return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation
63                                 .get(), null, null, null,ImmutableMap.<String,String>of());
64                     else
65                        return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(),
66                                 null, null, null,ImmutableMap.<String,String>of(), null,
67                                 null, new BaseMutableContentMetadata());
68                  }
69 
70               }), from.getToken());
71 
72   }
73}

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