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

COVERAGE SUMMARY FOR SOURCE FILE [BindDriveDataToPlainTextString.java]

nameclass, %method, %block, %line, %
BindDriveDataToPlainTextString.java100% (1/1)100% (2/2)100% (38/38)100% (10/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BindDriveDataToPlainTextString100% (1/1)100% (2/2)100% (38/38)100% (10/10)
BindDriveDataToPlainTextString (Function, ListOfMapsToListOfKeyValuesDelimite... 100% (1/1)100% (9/9)100% (4/4)
bindToRequest (HttpRequest, Object): HttpRequest 100% (1/1)100% (29/29)100% (6/6)

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.binders;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import java.util.Map;
24 
25import javax.inject.Inject;
26import javax.inject.Singleton;
27import javax.ws.rs.core.MediaType;
28 
29import org.jclouds.cloudsigma.domain.DriveData;
30import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
31import org.jclouds.http.HttpRequest;
32import org.jclouds.rest.Binder;
33 
34import com.google.common.base.Function;
35import com.google.common.collect.ImmutableSet;
36 
37/**
38 * 
39 * @author Adrian Cole
40 */
41@Singleton
42public class BindDriveDataToPlainTextString implements Binder {
43   private final Function<DriveData, Map<String, String>> createDriveRequestToMap;
44   private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
45 
46   @Inject
47   public BindDriveDataToPlainTextString(Function<DriveData, Map<String, String>> createDriveRequestToMap,
48         ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
49      this.createDriveRequestToMap = createDriveRequestToMap;
50      this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
51   }
52   @Override
53   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
54      checkArgument(payload instanceof DriveData, "this binder is only valid for DriveData!");
55      DriveData create = DriveData.class.cast(payload);
56      Map<String, String> map = createDriveRequestToMap.apply(create);
57      request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
58      request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
59      return request;
60   }
61}

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