EMMA Coverage Report (generated Wed Aug 10 12:30:04 EDT 2011)
[all classes][org.jclouds.rest.binders]

COVERAGE SUMMARY FOR SOURCE FILE [BindToJsonPayloadWrappedWith.java]

nameclass, %method, %block, %line, %
BindToJsonPayloadWrappedWith.java100% (1/1)100% (2/2)100% (26/26)100% (5/5)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BindToJsonPayloadWrappedWith100% (1/1)100% (2/2)100% (26/26)100% (5/5)
BindToJsonPayloadWrappedWith (BindToJsonPayload, String): void 100% (1/1)100% (15/15)100% (4/4)
bindToRequest (HttpRequest, Object): HttpRequest 100% (1/1)100% (11/11)100% (1/1)

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.rest.binders;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import javax.inject.Inject;
24 
25import org.jclouds.http.HttpRequest;
26import org.jclouds.rest.Binder;
27 
28import com.google.common.collect.ImmutableMap;
29import com.google.inject.assistedinject.Assisted;
30 
31/**
32 * Sometimes, cloud apis wrap requests inside an envelope. This addresses this.
33 * 
34 * @author Adrian Cole
35 */
36public class BindToJsonPayloadWrappedWith implements Binder {
37 
38   public static interface Factory {
39      BindToJsonPayloadWrappedWith create(String envelope);
40   }
41 
42   private final BindToJsonPayload jsonBinder;
43   private final String envelope;
44 
45   @Inject
46   BindToJsonPayloadWrappedWith(BindToJsonPayload jsonBinder, @Assisted String envelope) {
47      this.jsonBinder = checkNotNull(jsonBinder, "jsonBinder");
48      this.envelope = checkNotNull(envelope, "envelope");
49   }
50 
51   @Override
52   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
53      return jsonBinder.bindToRequest(request, (Object) ImmutableMap.of(envelope, checkNotNull(payload, "payload")));
54   }
55 
56}

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