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

COVERAGE SUMMARY FOR SOURCE FILE [AddServerOptions.java]

nameclass, %method, %block, %line, %
AddServerOptions.java100% (2/2)83%  (5/6)92%  (61/66)95%  (12.4/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AddServerOptions$Builder100% (1/1)67%  (2/3)83%  (15/18)80%  (4/5)
AddServerOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
asSandboxType (): AddServerOptions 100% (1/1)100% (7/7)100% (2/2)
withDescription (String): AddServerOptions 100% (1/1)100% (8/8)100% (2/2)
     
class AddServerOptions100% (1/1)100% (3/3)96%  (46/48)99%  (8.9/9)
asSandboxType (): AddServerOptions 100% (1/1)94%  (17/18)98%  (2.9/3)
withDescription (String): AddServerOptions 100% (1/1)96%  (26/27)99%  (4/4)
AddServerOptions (): void 100% (1/1)100% (3/3)100% (2/2)

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.gogrid.options;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkState;
23import static org.jclouds.gogrid.reference.GoGridQueryParams.DESCRIPTION_KEY;
24import static org.jclouds.gogrid.reference.GoGridQueryParams.IS_SANDBOX_KEY;
25 
26import org.jclouds.http.options.BaseHttpRequestOptions;
27 
28/**
29 * @author Oleksiy Yarmula
30 */
31public class AddServerOptions extends BaseHttpRequestOptions {
32 
33   public AddServerOptions withDescription(String description) {
34      checkArgument(description.length() <= 500, "Description cannot be longer than 500 characters");
35      checkState(!queryParameters.containsKey(DESCRIPTION_KEY),
36               "Can't have duplicate server description");
37      queryParameters.put(DESCRIPTION_KEY, description);
38      return this;
39   }
40 
41   /**
42    * Make server a sandbox instance. By default, it's not.
43    * 
44    * @return itself for convenience
45    */
46   public AddServerOptions asSandboxType() {
47      checkState(!queryParameters.containsKey(IS_SANDBOX_KEY),
48               "Can only have one sandbox option per server");
49      queryParameters.put(IS_SANDBOX_KEY, "true");
50      return this;
51   }
52 
53   public static class Builder {
54      /**
55       * @see AddServerOptions#withDescription(String)
56       */
57      public static AddServerOptions withDescription(String description) {
58         AddServerOptions options = new AddServerOptions();
59         return options.withDescription(description);
60      }
61 
62      /**
63       * @see AddServerOptions#asSandboxType()
64       */
65      public static AddServerOptions asSandboxType() {
66         AddServerOptions options = new AddServerOptions();
67         return options.asSandboxType();
68      }
69   }
70}

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