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

COVERAGE SUMMARY FOR SOURCE FILE [GroupAwareJob.java]

nameclass, %method, %block, %line, %
GroupAwareJob.java100% (1/1)40%  (4/10)61%  (52/85)47%  (8/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GroupAwareJob100% (1/1)40%  (4/10)61%  (52/85)47%  (8/17)
equals (Object): boolean 0%   (0/1)0%   (0/12)0%   (0/3)
execute (JobExecution): void 0%   (0/1)0%   (0/5)0%   (0/2)
getJobParametersIncrementer (): JobParametersIncrementer 0%   (0/1)0%   (0/4)0%   (0/1)
getJobParametersValidator (): JobParametersValidator 0%   (0/1)0%   (0/4)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/4)0%   (0/1)
isRestartable (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
GroupAwareJob (Job): void 100% (1/1)100% (5/5)100% (2/2)
GroupAwareJob (String, Job): void 100% (1/1)100% (9/9)100% (4/4)
getName (): String 100% (1/1)100% (21/21)100% (1/1)
toString (): String 100% (1/1)100% (17/17)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 */
16package org.springframework.batch.core.configuration.support;
17 
18import org.springframework.batch.core.Job;
19import org.springframework.batch.core.JobExecution;
20import org.springframework.batch.core.JobParametersIncrementer;
21import org.springframework.batch.core.JobParametersValidator;
22import org.springframework.util.ClassUtils;
23 
24/**
25 * A {@link Job} that can optionally prepend a group name to another job's name,
26 * to make it fit a naming convention for type or origin. E.g. the source job
27 * might be <code>overnightJob</code> and the group
28 * <code>financeDepartment</code>, which would result in a {@link Job} with
29 * identical functionality but named <code>financeDepartment.overnightJob</code>
30 * . The use of a "." separator for elements is deliberate, since it is a "safe"
31 * character in a <a href="http://www.w3.org/Addressing/URL">URL</a>.
32 * 
33 * 
34 * @author Dave Syer
35 * 
36 */
37public class GroupAwareJob implements Job {
38 
39        /**
40         * The separator between group and delegate job names in the final name
41         * given to this job.
42         */
43        private static final String SEPARATOR = ".";
44 
45        private final Job delegate;
46 
47        private final String groupName;
48 
49        /**
50         * Create a new {@link Job} with the delegate and no group name.
51         * 
52         * @param delegate a delegate for the features of a regular Job
53         */
54        public GroupAwareJob(Job delegate) {
55                this(null, delegate);
56        }
57 
58        /**
59         * Create a new {@link Job} with the given group name and delegate.
60         * 
61         * @param groupName the group name to prepend
62         * @param delegate a delegate for the features of a regular Job
63         */
64        public GroupAwareJob(String groupName, Job delegate) {
65                super();
66                this.groupName = groupName;
67                this.delegate = delegate;
68        }
69 
70        public void execute(JobExecution execution) {
71                delegate.execute(execution);
72        }
73        
74        /**
75         * Concatenates the group name and the delegate job name (joining with a
76         * ".").
77         * 
78         * @see org.springframework.batch.core.Job#getName()
79         */
80        public String getName() {
81                return groupName==null ? delegate.getName() : groupName + SEPARATOR + delegate.getName();
82        }
83 
84        public boolean isRestartable() {
85                return delegate.isRestartable();
86        }
87 
88        public JobParametersIncrementer getJobParametersIncrementer() {
89                return delegate.getJobParametersIncrementer();
90        }
91 
92        public JobParametersValidator getJobParametersValidator() {
93                return delegate.getJobParametersValidator();
94        }
95 
96        /*
97         * (non-Javadoc)
98         * 
99         * @see java.lang.Object#equals(java.lang.Object)
100         */
101        @Override
102        public boolean equals(Object obj) {
103                if (obj instanceof GroupAwareJob) {
104                        return ((GroupAwareJob) obj).delegate.equals(delegate);
105                }
106                return false;
107        }
108 
109        /*
110         * (non-Javadoc)
111         * 
112         * @see java.lang.Object#hashCode()
113         */
114        @Override
115        public int hashCode() {
116                return delegate.hashCode();
117        }
118        
119        @Override
120        public String toString() {
121                return ClassUtils.getShortName(delegate.getClass()) + ": [name=" + getName() + "]";
122        }
123 
124}

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