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

COVERAGE SUMMARY FOR SOURCE FILE [GetJobListOptions.java]

nameclass, %method, %block, %line, %
GetJobListOptions.java100% (2/2)80%  (12/15)80%  (155/193)80%  (27.2/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GetJobListOptions$Builder100% (1/1)50%  (2/4)55%  (12/22)50%  (2/4)
GetJobListOptions$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
maxItems (int): GetJobListOptions 0%   (0/1)0%   (0/7)0%   (0/1)
latestJobForObjectByName (String): GetJobListOptions 100% (1/1)100% (6/6)100% (1/1)
startDate (Date): GetJobListOptions 100% (1/1)100% (6/6)100% (1/1)
     
class GetJobListOptions100% (1/1)91%  (10/11)84%  (143/171)83%  (25.7/31)
withOwner (String): GetJobListOptions 0%   (0/1)0%   (0/18)0%   (0/3)
equals (Object): boolean 100% (1/1)83%  (19/23)67%  (4/6)
onlyForObjectName (String): GetJobListOptions 100% (1/1)94%  (17/18)98%  (2.9/3)
maxItemsNumber (Integer): GetJobListOptions 100% (1/1)95%  (18/19)98%  (2.9/3)
onlyForObjectType (ObjectType): GetJobListOptions 100% (1/1)95%  (18/19)98%  (2.9/3)
onlyForState (JobState): GetJobListOptions 100% (1/1)95%  (18/19)98%  (2.9/3)
withEndDate (Date): GetJobListOptions 100% (1/1)95%  (19/20)98%  (3/3)
withStartDate (Date): GetJobListOptions 100% (1/1)95%  (19/20)98%  (3/3)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
GetJobListOptions (): void 100% (1/1)100% (3/3)100% (2/2)
latestJobForObjectByName (String): GetJobListOptions 100% (1/1)100% (7/7)100% (1/1)

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.checkState;
22import static org.jclouds.gogrid.reference.GoGridQueryParams.END_DATE_KEY;
23import static org.jclouds.gogrid.reference.GoGridQueryParams.JOB_OBJECT_TYPE_KEY;
24import static org.jclouds.gogrid.reference.GoGridQueryParams.JOB_STATE_KEY;
25import static org.jclouds.gogrid.reference.GoGridQueryParams.MAX_NUMBER_KEY;
26import static org.jclouds.gogrid.reference.GoGridQueryParams.OBJECT_KEY;
27import static org.jclouds.gogrid.reference.GoGridQueryParams.OWNER_KEY;
28import static org.jclouds.gogrid.reference.GoGridQueryParams.START_DATE_KEY;
29 
30import java.util.Date;
31 
32import org.jclouds.gogrid.domain.JobState;
33import org.jclouds.gogrid.domain.ObjectType;
34import org.jclouds.http.options.BaseHttpRequestOptions;
35 
36/**
37 * @author Oleksiy Yarmula
38 */
39public class GetJobListOptions extends BaseHttpRequestOptions {
40 
41   public static final GetJobListOptions NONE = new GetJobListOptions();
42 
43   public GetJobListOptions maxItemsNumber(Integer maxNumber) {
44      checkState(!queryParameters.containsKey(MAX_NUMBER_KEY), "Can't have duplicate parameter of max returned items");
45      queryParameters.put(MAX_NUMBER_KEY, maxNumber.toString());
46      return this;
47   }
48 
49   public GetJobListOptions withStartDate(Date startDate) {
50      checkState(!queryParameters.containsKey(START_DATE_KEY), "Can't have duplicate start date for filtering");
51      queryParameters.put(START_DATE_KEY, String.valueOf(startDate.getTime()));
52      return this;
53   }
54 
55   public GetJobListOptions withEndDate(Date endDate) {
56      checkState(!queryParameters.containsKey(END_DATE_KEY), "Can't have duplicate end date for filtering");
57      queryParameters.put(END_DATE_KEY, String.valueOf(endDate.getTime()));
58      return this;
59   }
60 
61   public GetJobListOptions withOwner(String owner) {
62      checkState(!queryParameters.containsKey(OWNER_KEY), "Can't have duplicate owner name for filtering");
63      queryParameters.put(OWNER_KEY, owner);
64      return this;
65   }
66 
67   public GetJobListOptions onlyForState(JobState jobState) {
68      checkState(!queryParameters.containsKey(JOB_STATE_KEY), "Can't have duplicate job state for filtering");
69      queryParameters.put(JOB_STATE_KEY, jobState.toString());
70      return this;
71   }
72 
73   public GetJobListOptions onlyForObjectType(ObjectType objectType) {
74      checkState(!queryParameters.containsKey(JOB_OBJECT_TYPE_KEY), "Can't have duplicate object type for filtering");
75      queryParameters.put(JOB_OBJECT_TYPE_KEY, objectType.toString());
76      return this;
77   }
78 
79   public GetJobListOptions onlyForObjectName(String objectName) {
80      checkState(!queryParameters.containsKey(OBJECT_KEY), "Can't have duplicate object name for filtering");
81      queryParameters.put(OBJECT_KEY, objectName);
82      return this;
83   }
84 
85   public GetJobListOptions latestJobForObjectByName(String serverName) {
86      return maxItemsNumber(1).onlyForObjectName(serverName);
87   }
88 
89   /*
90    * This method is intended for testing
91    */
92   @Override
93   public boolean equals(Object o) {
94      if (this == o)
95         return true;
96      if (o == null || getClass() != o.getClass())
97         return false;
98 
99      GetJobListOptions options = (GetJobListOptions) o;
100 
101      return buildQueryParameters().equals(options.buildQueryParameters());
102   }
103 
104   public static class Builder {
105 
106      public static GetJobListOptions maxItems(int maxNumber) {
107         return new GetJobListOptions().maxItemsNumber(maxNumber);
108      }
109      
110      public static GetJobListOptions startDate(Date startDate){
111         return new GetJobListOptions().withStartDate(startDate);
112      }
113 
114      public static GetJobListOptions latestJobForObjectByName(String serverName) {
115         return new GetJobListOptions().latestJobForObjectByName(serverName);
116      }
117   }
118 
119}

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