EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.gogrid.options]

COVERAGE SUMMARY FOR SOURCE FILE [GetImageListOptions.java]

nameclass, %method, %block, %line, %
GetImageListOptions.java50%  (1/2)36%  (4/11)39%  (56/145)43%  (10.3/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GetImageListOptions$Builder0%   (0/1)0%   (0/4)0%   (0/31)0%   (0/5)
GetImageListOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
inDatacenter (String): GetImageListOptions 0%   (0/1)0%   (0/10)0%   (0/2)
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 *
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.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),
40               "Can't have duplicate image type restrictions");
41      queryParameters.put(IMAGE_TYPE_KEY, imageType.toString());
42      return this;
43   }
44 
45   public GetImageListOptions setState(ServerImageState imageState) {
46      checkState(!queryParameters.containsKey(IMAGE_STATE_KEY),
47               "Can't have duplicate image state restrictions");
48      queryParameters.put(IMAGE_STATE_KEY, imageState.toString());
49      return this;
50   }
51 
52   public GetImageListOptions onlyPublic() {
53      checkState(!queryParameters.containsKey(IS_PUBLIC_KEY),
54               "Can't have duplicate image visibility restrictions");
55      queryParameters.put(IS_PUBLIC_KEY, "true");
56      return this;
57   }
58 
59   public GetImageListOptions onlyPrivate() {
60      checkState(!queryParameters.containsKey(IS_PUBLIC_KEY),
61               "Can't have duplicate image visibility restrictions");
62      queryParameters.put(IS_PUBLIC_KEY, "false");
63      return this;
64   }
65 
66   public GetImageListOptions inDatacenter(String datacenterId) {
67      checkState(!queryParameters.containsKey(DATACENTER_KEY), "Can't have duplicate datacenter id");
68      queryParameters.put(DATACENTER_KEY, datacenterId);
69      return this;
70   }
71 
72   public GetImageListOptions maxItemsNumber(Integer maxNumber) {
73      checkState(!queryParameters.containsKey(MAX_NUMBER_KEY),
74               "Can't have duplicate parameter of max returned items");
75      queryParameters.put(MAX_NUMBER_KEY, maxNumber.toString());
76      return this;
77   }
78 
79   public static class Builder {
80      public GetImageListOptions inDatacenter(String datacenterId) {
81         GetImageListOptions getImageListOptions = new GetImageListOptions();
82         return getImageListOptions.inDatacenter(checkNotNull(datacenterId));
83      }
84 
85      public GetImageListOptions publicWebServers() {
86         return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(
87                  ServerImageType.WEB_APPLICATION_SERVER).onlyPublic();
88      }
89 
90      public GetImageListOptions publicDatabaseServers() {
91         return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(
92                  ServerImageType.DATABASE_SERVER).onlyPublic();
93      }
94   }
95 
96}

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