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

COVERAGE SUMMARY FOR SOURCE FILE [GetImageListOptions.java]

nameclass, %method, %block, %line, %
GetImageListOptions.java50%  (1/2)33%  (4/12)37%  (56/151)43%  (10.3/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GetImageListOptions$Builder0%   (0/1)0%   (0/5)0%   (0/37)0%   (0/5)
GetImageListOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
inDatacenter (String): GetImageListOptions 0%   (0/1)0%   (0/9)0%   (0/1)
maxItems (int): GetImageListOptions 0%   (0/1)0%   (0/7)0%   (0/1)
publicDatabaseServers (): GetImageListOptions 0%   (0/1)0%   (0/9)0%   (0/1)
publicWebServers (): GetImageListOptions 0%   (0/1)0%   (0/9)0%   (0/1)
     
class GetImageListOptions100% (1/1)57%  (4/7)49%  (56/114)54%  (10.8/20)
inDatacenter (String): GetImageListOptions 0%   (0/1)0%   (0/18)0%   (0/3)
maxItemsNumber (Integer): GetImageListOptions 0%   (0/1)0%   (0/19)0%   (0/3)
onlyPrivate (): GetImageListOptions 0%   (0/1)0%   (0/18)0%   (0/3)
onlyPublic (): GetImageListOptions 100% (1/1)94%  (17/18)98%  (2.9/3)
setState (ServerImageState): GetImageListOptions 100% (1/1)95%  (18/19)98%  (2.9/3)
setType (ServerImageType): GetImageListOptions 100% (1/1)95%  (18/19)98%  (2.9/3)
GetImageListOptions (): void 100% (1/1)100% (3/3)100% (2/2)

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.gogrid.options;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23import static org.jclouds.gogrid.reference.GoGridQueryParams.DATACENTER_KEY;
24import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_STATE_KEY;
25import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_TYPE_KEY;
26import static org.jclouds.gogrid.reference.GoGridQueryParams.IS_PUBLIC_KEY;
27import static org.jclouds.gogrid.reference.GoGridQueryParams.MAX_NUMBER_KEY;
28 
29import org.jclouds.gogrid.domain.ServerImageState;
30import org.jclouds.gogrid.domain.ServerImageType;
31import org.jclouds.http.options.BaseHttpRequestOptions;
32 
33/**
34 * @author Oleksiy Yarmula
35 */
36public class GetImageListOptions extends BaseHttpRequestOptions {
37 
38   public GetImageListOptions setType(ServerImageType imageType) {
39      checkState(!queryParameters.containsKey(IMAGE_TYPE_KEY), "Can't have duplicate image type restrictions");
40      queryParameters.put(IMAGE_TYPE_KEY, imageType.toString());
41      return this;
42   }
43 
44   public GetImageListOptions setState(ServerImageState imageState) {
45      checkState(!queryParameters.containsKey(IMAGE_STATE_KEY), "Can't have duplicate image state restrictions");
46      queryParameters.put(IMAGE_STATE_KEY, imageState.toString());
47      return this;
48   }
49 
50   public GetImageListOptions onlyPublic() {
51      checkState(!queryParameters.containsKey(IS_PUBLIC_KEY), "Can't have duplicate image visibility restrictions");
52      queryParameters.put(IS_PUBLIC_KEY, "true");
53      return this;
54   }
55 
56   public GetImageListOptions onlyPrivate() {
57      checkState(!queryParameters.containsKey(IS_PUBLIC_KEY), "Can't have duplicate image visibility restrictions");
58      queryParameters.put(IS_PUBLIC_KEY, "false");
59      return this;
60   }
61 
62   public GetImageListOptions inDatacenter(String datacenterId) {
63      checkState(!queryParameters.containsKey(DATACENTER_KEY), "Can't have duplicate datacenter id");
64      queryParameters.put(DATACENTER_KEY, datacenterId);
65      return this;
66   }
67 
68   public GetImageListOptions maxItemsNumber(Integer maxNumber) {
69      checkState(!queryParameters.containsKey(MAX_NUMBER_KEY), "Can't have duplicate parameter of max returned items");
70      queryParameters.put(MAX_NUMBER_KEY, maxNumber.toString());
71      return this;
72   }
73 
74   public static class Builder {
75      public static GetImageListOptions maxItems(int maxNumber) {
76         return new GetImageListOptions().maxItemsNumber(maxNumber);
77      }
78 
79      public static GetImageListOptions inDatacenter(String datacenterId) {
80         return new GetImageListOptions().inDatacenter(checkNotNull(datacenterId, "datacenterId"));
81      }
82 
83      public static GetImageListOptions publicWebServers() {
84         return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(
85                  ServerImageType.WEB_APPLICATION_SERVER).onlyPublic();
86      }
87 
88      public static GetImageListOptions publicDatabaseServers() {
89         return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(ServerImageType.DATABASE_SERVER)
90                  .onlyPublic();
91      }
92   }
93 
94}

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