EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.core]

COVERAGE SUMMARY FOR SOURCE FILE [JobParameter.java]

nameclass, %method, %block, %line, %
JobParameter.java100% (2/2)100% (13/13)94%  (179/191)90%  (27/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JobParameter100% (1/1)100% (9/9)91%  (121/133)89%  (25/28)
getValue (): Object 100% (1/1)60%  (12/20)67%  (2/3)
equals (Object): boolean 100% (1/1)88%  (30/34)67%  (4/6)
JobParameter (Date): void 100% (1/1)100% (9/9)100% (4/4)
JobParameter (Double): void 100% (1/1)100% (9/9)100% (4/4)
JobParameter (Long): void 100% (1/1)100% (9/9)100% (4/4)
JobParameter (String): void 100% (1/1)100% (9/9)100% (4/4)
getType (): JobParameter$ParameterType 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (15/15)100% (1/1)
toString (): String 100% (1/1)100% (25/25)100% (1/1)
     
class JobParameter$ParameterType100% (1/1)100% (4/4)100% (58/58)100% (2/2)
<static initializer> 100% (1/1)100% (44/44)100% (2/2)
JobParameter$ParameterType (String, int): void 100% (1/1)100% (5/5)100% (1/1)
valueOf (String): JobParameter$ParameterType 100% (1/1)100% (5/5)100% (1/1)
values (): JobParameter$ParameterType [] 100% (1/1)100% (4/4)100% (1/1)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.core;
18 
19import java.io.Serializable;
20import java.util.Date;
21 
22/**
23 * Domain representation of a parameter to a batch job. Only the following types
24 * can be parameters: String, Long, Date, and Double.
25 * 
26 * @author Lucas Ward
27 * @author Dave Syer
28 * @since 2.0
29 * 
30 */
31public class JobParameter implements Serializable {
32 
33        private final Object parameter;
34 
35        private final ParameterType parameterType;
36 
37        /**
38         * Construct a new JobParameter as a String.
39         */
40        public JobParameter(String parameter) {
41                this.parameter = parameter;
42                parameterType = ParameterType.STRING;
43        }
44 
45        /**
46         * Construct a new JobParameter as a Long.
47         * 
48         * @param parameter
49         */
50        public JobParameter(Long parameter) {
51                this.parameter = parameter;
52                parameterType = ParameterType.LONG;
53        }
54 
55        /**
56         * Construct a new JobParameter as a Date.
57         * 
58         * @param parameter
59         */
60        public JobParameter(Date parameter) {
61                this.parameter = parameter;
62                parameterType = ParameterType.DATE;
63        }
64 
65        /**
66         * Construct a new JobParameter as a Double.
67         * 
68         * @param parameter
69         */
70        public JobParameter(Double parameter) {
71                this.parameter = parameter;
72                parameterType = ParameterType.DOUBLE;
73        }
74 
75        /**
76         * @return the value contained within this JobParameter.
77         */
78        public Object getValue() {
79 
80                if (parameter != null && parameter.getClass().isInstance(Date.class)) {
81                        return new Date(((Date) parameter).getTime());
82                }
83                else {
84                        return parameter;
85                }
86        }
87 
88        /**
89         * @return a ParameterType representing the type of this parameter.
90         */
91        public ParameterType getType() {
92                return parameterType;
93        }
94 
95        @Override
96        public boolean equals(Object obj) {
97                if (obj instanceof JobParameter == false) {
98                        return false;
99                }
100 
101                if (this == obj) {
102                        return true;
103                }
104 
105                JobParameter rhs = (JobParameter) obj;
106                return parameter==null ? rhs.parameter==null && parameterType==rhs.parameterType: parameter.equals(rhs.parameter);
107        }
108 
109        @Override
110        public String toString() {
111                return parameter == null ? null : (parameterType == ParameterType.DATE ? "" + ((Date) parameter).getTime()
112                                : parameter.toString());
113        }
114 
115        public int hashCode() {
116                return 7 + 21 * (parameter == null ? parameterType.hashCode() : parameter.hashCode());
117        }
118 
119        /**
120         * Enumeration representing the type of a JobParameter.
121         */
122        public enum ParameterType {
123 
124                STRING, DATE, LONG, DOUBLE;
125        }
126}

[all classes][org.springframework.batch.core]
EMMA 2.0.5312 (C) Vladimir Roubtsov