Skip to content

Commit 52f21bd

Browse files
committed
Polishing
(cherry picked from commit 22ca7ac)
1 parent 3185f67 commit 52f21bd

File tree

8 files changed

+32
-31
lines changed

8 files changed

+32
-31
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,12 @@ public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> a
509509
//---------------------------------------------------------------------
510510

511511
public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue) {
512-
Assert.notNull(dependencyType, "Type must not be null");
512+
Assert.notNull(dependencyType, "Dependency type must not be null");
513513
if (autowiredValue != null) {
514-
Assert.isTrue((autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue)),
515-
"Value [" + autowiredValue + "] does not implement specified type [" + dependencyType.getName() + "]");
514+
if (!(autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue))) {
515+
throw new IllegalArgumentException("Value [" + autowiredValue +
516+
"] does not implement specified dependency type [" + dependencyType.getName() + "]");
517+
}
516518
this.resolvableDependencies.put(dependencyType, autowiredValue);
517519
}
518520
}

spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* <li>"0 0 * * * *" = the top of every hour of every day.</li>
4343
* <li>"*&#47;10 * * * * *" = every ten seconds.</li>
4444
* <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li>
45+
* <li>"0 * 6,19 * * *" = 6:00 AM and 7:00 PM every day.</li>
4546
* <li>"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li>
4647
* <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li>
4748
* <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li>
@@ -115,7 +116,7 @@ public Date next(Date date) {
115116
/*
116117
The plan:
117118
118-
1 Round up to the next whole second
119+
1 Start with whole second (rounding up if necessary)
119120
120121
2 If seconds match move on, otherwise find the next match:
121122
2.1 If next match is in the next minute then roll forwards
@@ -127,8 +128,6 @@ public Date next(Date date) {
127128
4 If hour matches move on, otherwise find the next match
128129
4.1 If next match is in the next day then roll forwards,
129130
4.2 Reset the minutes and seconds and go to 2
130-
131-
...
132131
*/
133132

134133
Calendar calendar = new GregorianCalendar();
@@ -409,7 +408,7 @@ public int hashCode() {
409408

410409
@Override
411410
public String toString() {
412-
return (getClass().getSimpleName() + ": " + this.expression);
411+
return getClass().getSimpleName() + ": " + this.expression;
413412
}
414413

415414
}

spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,13 +39,13 @@
3939
* Allows for objects written using dynamic languages to be easily exposed with
4040
* the {@link org.springframework.beans.factory.BeanFactory}.
4141
*
42-
* <p>The script for each object can be specified either as a reference to the Resource
43-
* containing it (using the '{@code script-source}' attribute) or inline in the XML configuration
44-
* itself (using the '{@code inline-script}' attribute.
42+
* <p>The script for each object can be specified either as a reference to the
43+
* resource containing it (using the '{@code script-source}' attribute) or inline
44+
* in the XML configuration itself (using the '{@code inline-script}' attribute.
4545
*
46-
* <p>By default, dynamic objects created with these tags are <strong>not</strong> refreshable.
47-
* To enable refreshing, specify the refresh check delay for each object (in milliseconds) using the
48-
* '{@code refresh-check-delay}' attribute.
46+
* <p>By default, dynamic objects created with these tags are <strong>not</strong>
47+
* refreshable. To enable refreshing, specify the refresh check delay for each
48+
* object (in milliseconds) using the '{@code refresh-check-delay}' attribute.
4949
*
5050
* @author Rob Harrop
5151
* @author Rod Johnson
@@ -171,14 +171,13 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
171171
// Attach any refresh metadata.
172172
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
173173
if (StringUtils.hasText(refreshCheckDelay)) {
174-
bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, new Long(refreshCheckDelay));
174+
bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, Long.valueOf(refreshCheckDelay));
175175
}
176176

177177
// Attach any proxy target class metadata.
178178
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
179179
if (StringUtils.hasText(proxyTargetClass)) {
180-
Boolean flag = new Boolean(proxyTargetClass);
181-
bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, flag);
180+
bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, Boolean.valueOf(proxyTargetClass));
182181
}
183182

184183
// Add constructor arguments.
@@ -213,7 +212,7 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
213212
*/
214213
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
215214
boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
216-
List elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
215+
List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
217216
if (hasScriptSource && !elements.isEmpty()) {
218217
readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
219218
return null;
@@ -222,7 +221,7 @@ else if (hasScriptSource) {
222221
return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
223222
}
224223
else if (!elements.isEmpty()) {
225-
Element inlineElement = (Element) elements.get(0);
224+
Element inlineElement = elements.get(0);
226225
return "inline:" + DomUtils.getTextValue(inlineElement);
227226
}
228227
else {

spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
4040
LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry());
4141
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
4242
if (StringUtils.hasText(refreshCheckDelay)) {
43-
bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay));
43+
bd.getPropertyValues().add("defaultRefreshCheckDelay", Long.valueOf(refreshCheckDelay));
4444
}
4545
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
4646
if (StringUtils.hasText(proxyTargetClass)) {

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -161,9 +161,9 @@ public Connection getConnection() {
161161
*/
162162
public boolean supportsSavepoints() throws SQLException {
163163
if (this.savepointsSupported == null) {
164-
this.savepointsSupported = new Boolean(getConnection().getMetaData().supportsSavepoints());
164+
this.savepointsSupported = getConnection().getMetaData().supportsSavepoints();
165165
}
166-
return this.savepointsSupported.booleanValue();
166+
return this.savepointsSupported;
167167
}
168168

169169
/**

spring-jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -95,7 +95,7 @@ protected BeanDefinition parseContainer(Element listenerEle, Element containerEl
9595

9696
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);
9797
if (StringUtils.hasText(prefetch)) {
98-
configDef.getPropertyValues().add("prefetchSize", new Integer(prefetch));
98+
configDef.getPropertyValues().add("prefetchSize", Integer.valueOf(prefetch));
9999
}
100100

101101
String phase = containerEle.getAttribute(PHASE_ATTRIBUTE);

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
4646
/** The default name of the exception attribute: "exception". */
4747
public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
4848

49+
4950
private Properties exceptionMappings;
5051

5152
private Class<?>[] excludedExceptions;
@@ -108,7 +109,7 @@ public void setDefaultErrorView(String defaultErrorView) {
108109
public void setStatusCodes(Properties statusCodes) {
109110
for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) {
110111
String viewName = (String) enumeration.nextElement();
111-
Integer statusCode = new Integer(statusCodes.getProperty(viewName));
112+
Integer statusCode = Integer.valueOf(statusCodes.getProperty(viewName));
112113
this.statusCodes.put(viewName, statusCode);
113114
}
114115
}

spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -312,7 +312,7 @@ protected final void initApplicationContext() throws ApplicationContextException
312312
"'reportDataKey' for main report is required when specifying a value for 'subReportDataKeys'");
313313
}
314314
this.subReports = new HashMap<String, JasperReport>(this.subReportUrls.size());
315-
for (Enumeration urls = this.subReportUrls.propertyNames(); urls.hasMoreElements();) {
315+
for (Enumeration<?> urls = this.subReportUrls.propertyNames(); urls.hasMoreElements();) {
316316
String key = (String) urls.nextElement();
317317
String path = this.subReportUrls.getProperty(key);
318318
Resource resource = getApplicationContext().getResource(path);
@@ -383,7 +383,7 @@ else if ("false".equals(str)) {
383383
else if (str.length() > 0 && Character.isDigit(str.charAt(0))) {
384384
// Looks like a number... let's try.
385385
try {
386-
return new Integer(str);
386+
return Integer.valueOf(str);
387387
}
388388
catch (NumberFormatException ex) {
389389
// OK, then let's keep it as a String value.

0 commit comments

Comments
 (0)