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

COVERAGE SUMMARY FOR SOURCE FILE [RebuildServerOptions.java]

nameclass, %method, %block, %line, %
RebuildServerOptions.java100% (2/2)67%  (4/6)82%  (42/51)87%  (10.4/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RebuildServerOptions$Builder100% (1/1)50%  (1/2)73%  (8/11)67%  (2/3)
RebuildServerOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
withImage (int): RebuildServerOptions 100% (1/1)100% (8/8)100% (2/2)
     
class RebuildServerOptions100% (1/1)75%  (3/4)85%  (34/40)89%  (8.9/10)
bindToRequest (HttpRequest, Object): HttpRequest 0%   (0/1)0%   (0/5)0%   (0/1)
withImage (int): RebuildServerOptions 100% (1/1)92%  (12/13)97%  (2.9/3)
RebuildServerOptions (): void 100% (1/1)100% (3/3)100% (2/2)
bindToRequest (HttpRequest, Map): HttpRequest 100% (1/1)100% (19/19)100% (4/4)

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.cloudservers.options;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22 
23import java.util.Map;
24 
25import javax.inject.Inject;
26 
27import org.jclouds.http.HttpRequest;
28import org.jclouds.rest.MapBinder;
29import org.jclouds.rest.binders.BindToJsonPayload;
30 
31import com.google.common.collect.ImmutableMap;
32import com.google.common.collect.Maps;
33 
34/**
35 * 
36 * 
37 * @author Adrian Cole
38 * 
39 */
40public class RebuildServerOptions implements MapBinder {
41   @Inject
42   private BindToJsonPayload jsonBinder;
43   Integer imageId;
44 
45   @Override
46   public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
47      Map<String, Integer> image = Maps.newHashMap();
48      if (imageId != null)
49         image.put("imageId", imageId);
50      return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
51   }
52 
53   @Override
54   public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
55      throw new IllegalStateException("RebuildServer is a POST operation");
56   }
57 
58   /**
59    * 
60    * @param id
61    *           of the image to rebuild the server with.
62    */
63   public RebuildServerOptions withImage(int id) {
64      checkArgument(id > 0, "server id must be a positive number");
65      this.imageId = id;
66      return this;
67   }
68 
69   public static class Builder {
70 
71      /**
72       * @see RebuildServerOptions#withImage(int)
73       */
74      public static RebuildServerOptions withImage(int id) {
75         RebuildServerOptions options = new RebuildServerOptions();
76         return options.withImage(id);
77      }
78   }
79}

[all classes][org.jclouds.cloudservers.options]
EMMA 2.0.5312 (C) Vladimir Roubtsov