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

COVERAGE SUMMARY FOR SOURCE FILE [GetJobListOptions.java]

nameclass, %method, %block, %line, %
GetJobListOptions.java100% (2/2)92%  (12/13)84%  (152/180)87%  (26/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GetJobListOptions100% (1/1)90%  (9/10)83%  (136/164)86%  (24/28)
withOwner (String): GetJobListOptions 0%   (0/1)0%   (0/18)0%   (0/3)
equals (Object): boolean 100% (1/1)83%  (19/23)84%  (3.4/4)
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)
     
class GetJobListOptions$Builder100% (1/1)100% (3/3)100% (16/16)100% (3/3)
GetJobListOptions$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
create (): GetJobListOptions 100% (1/1)100% (4/4)100% (1/1)
latestJobForObjectByName (String): GetJobListOptions 100% (1/1)100% (9/9)100% (1/1)

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

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