Skip to content

Commit b6677cc

Browse files
committed
Polishing
1 parent 6c977e9 commit b6677cc

File tree

16 files changed

+82
-87
lines changed

16 files changed

+82
-87
lines changed

spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java

Lines changed: 4 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-2020 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.
@@ -30,13 +30,14 @@ public class AdviceEntry implements ParseState.Entry {
3030

3131

3232
/**
33-
* Creates a new instance of the {@link AdviceEntry} class.
34-
* @param kind the kind of advice represented by this entry (before, after, around, etc.)
33+
* Create a new {@code AdviceEntry} instance.
34+
* @param kind the kind of advice represented by this entry (before, after, around)
3535
*/
3636
public AdviceEntry(String kind) {
3737
this.kind = kind;
3838
}
3939

40+
4041
@Override
4142
public String toString() {
4243
return "Advice (" + this.kind + ")";

spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java

Lines changed: 3 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-2020 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.
@@ -30,13 +30,14 @@ public class AdvisorEntry implements ParseState.Entry {
3030

3131

3232
/**
33-
* Creates a new instance of the {@link AdvisorEntry} class.
33+
* Create a new {@code AdvisorEntry} instance.
3434
* @param name the bean name of the advisor
3535
*/
3636
public AdvisorEntry(String name) {
3737
this.name = name;
3838
}
3939

40+
4041
@Override
4142
public String toString() {
4243
return "Advisor '" + this.name + "'";

spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -34,7 +34,7 @@ public class AspectEntry implements ParseState.Entry {
3434

3535

3636
/**
37-
* Create a new AspectEntry.
37+
* Create a new {@code AspectEntry} instance.
3838
* @param id the id of the aspect element
3939
* @param ref the bean name referenced by this aspect element
4040
*/
@@ -43,6 +43,7 @@ public AspectEntry(String id, String ref) {
4343
this.ref = ref;
4444
}
4545

46+
4647
@Override
4748
public String toString() {
4849
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" : "ref='" + this.ref + "'");

spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java

Lines changed: 4 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-2020 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.
@@ -28,14 +28,16 @@ public class PointcutEntry implements ParseState.Entry {
2828

2929
private final String name;
3030

31+
3132
/**
32-
* Creates a new instance of the {@link PointcutEntry} class.
33+
* Create a new {@code PointcutEntry} instance.
3334
* @param name the bean name of the pointcut
3435
*/
3536
public PointcutEntry(String name) {
3637
this.name = name;
3738
}
3839

40+
3941
@Override
4042
public String toString() {
4143
return "Pointcut '" + this.name + "'";

spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanEntry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -24,11 +24,11 @@
2424
*/
2525
public class BeanEntry implements ParseState.Entry {
2626

27-
private String beanDefinitionName;
27+
private final String beanDefinitionName;
2828

2929

3030
/**
31-
* Creates a new instance of {@link BeanEntry} class.
31+
* Create a new {@code BeanEntry} instance.
3232
* @param beanDefinitionName the name of the associated bean definition
3333
*/
3434
public BeanEntry(String beanDefinitionName) {

spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,17 @@
2020

2121
/**
2222
* Simple {@link Stack}-based structure for tracking the logical position during
23-
* a parsing process. {@link Entry entries} are added to the stack at
24-
* each point during the parse phase in a reader-specific manner.
23+
* a parsing process. {@link Entry entries} are added to the stack at each point
24+
* during the parse phase in a reader-specific manner.
2525
*
2626
* <p>Calling {@link #toString()} will render a tree-style view of the current logical
27-
* position in the parse phase. This representation is intended for use in
28-
* error messages.
27+
* position in the parse phase. This representation is intended for use in error messages.
2928
*
3029
* @author Rob Harrop
3130
* @since 2.0
3231
*/
3332
public final class ParseState {
3433

35-
/**
36-
* Tab character used when rendering the tree-style representation.
37-
*/
38-
private static final char TAB = '\t';
39-
4034
/**
4135
* Internal {@link Stack} storage.
4236
*/
@@ -51,7 +45,7 @@ public ParseState() {
5145
}
5246

5347
/**
54-
* Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone}
48+
* Create a new {@code ParseState} whose {@link Stack} is a clone
5549
* of that of the passed in {@code ParseState}.
5650
*/
5751
@SuppressWarnings("unchecked")
@@ -79,7 +73,7 @@ public void pop() {
7973
* {@code null} if the {@link Stack} is empty.
8074
*/
8175
public Entry peek() {
82-
return this.state.empty() ? null : this.state.peek();
76+
return (this.state.empty() ? null : this.state.peek());
8377
}
8478

8579
/**
@@ -96,16 +90,18 @@ public ParseState snapshot() {
9690
*/
9791
@Override
9892
public String toString() {
99-
StringBuilder sb = new StringBuilder();
100-
for (int x = 0; x < this.state.size(); x++) {
101-
if (x > 0) {
93+
StringBuilder sb = new StringBuilder(64);
94+
int i = 0;
95+
for (ParseState.Entry entry : this.state) {
96+
if (i > 0) {
10297
sb.append('\n');
103-
for (int y = 0; y < x; y++) {
104-
sb.append(TAB);
98+
for (int j = 0; j < i; j++) {
99+
sb.append('\t');
105100
}
106101
sb.append("-> ");
107102
}
108-
sb.append(this.state.get(x));
103+
sb.append(entry);
104+
i++;
109105
}
110106
return sb.toString();
111107
}

spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java

Lines changed: 3 additions & 5 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-2020 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.
@@ -30,14 +30,12 @@ public class PropertyEntry implements ParseState.Entry {
3030

3131

3232
/**
33-
* Creates a new instance of the {@link PropertyEntry} class.
33+
* Create a new {@code PropertyEntry} instance.
3434
* @param name the name of the JavaBean property represented by this instance
35-
* @throws IllegalArgumentException if the supplied {@code name} is {@code null}
36-
* or consists wholly of whitespace
3735
*/
3836
public PropertyEntry(String name) {
3937
if (!StringUtils.hasText(name)) {
40-
throw new IllegalArgumentException("Invalid property name '" + name + "'.");
38+
throw new IllegalArgumentException("Invalid property name '" + name + "'");
4139
}
4240
this.name = name;
4341
}

spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java

Lines changed: 8 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-2020 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.
@@ -26,16 +26,21 @@
2626
*/
2727
public class QualifierEntry implements ParseState.Entry {
2828

29-
private String typeName;
29+
private final String typeName;
3030

3131

32+
/**
33+
* Create a new {@code QualifierEntry} instance.
34+
* @param typeName the name of the qualifier type
35+
*/
3236
public QualifierEntry(String typeName) {
3337
if (!StringUtils.hasText(typeName)) {
34-
throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'.");
38+
throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'");
3539
}
3640
this.typeName = typeName;
3741
}
3842

43+
3944
@Override
4045
public String toString() {
4146
return "Qualifier '" + this.typeName + "'";

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -38,7 +38,7 @@ public class ReplaceOverride extends MethodOverride {
3838

3939
private final String methodReplacerBeanName;
4040

41-
private List<String> typeIdentifiers = new LinkedList<String>();
41+
private final List<String> typeIdentifiers = new LinkedList<String>();
4242

4343

4444
/**
@@ -69,6 +69,7 @@ public void addTypeIdentifier(String identifier) {
6969
this.typeIdentifiers.add(identifier);
7070
}
7171

72+
7273
@Override
7374
public boolean matches(Method method) {
7475
if (!method.getName().equals(getMethodName())) {

spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java

Lines changed: 7 additions & 7 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-2020 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.
@@ -119,7 +119,7 @@ public Object lookup(String lookupName) throws NameNotFoundException {
119119
if (logger.isDebugEnabled()) {
120120
logger.debug("Static JNDI lookup: [" + name + "]");
121121
}
122-
if ("".equals(name)) {
122+
if (name.isEmpty()) {
123123
return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
124124
}
125125
Object found = this.boundObjects.get(name);
@@ -293,12 +293,12 @@ public Name composeName(Name name, Name prefix) throws NamingException {
293293
}
294294

295295

296-
private static abstract class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
296+
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
297297

298-
private Iterator<T> iterator;
298+
private final Iterator<T> iterator;
299299

300300
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
301-
if (!"".equals(proot) && !proot.endsWith("/")) {
301+
if (!proot.isEmpty() && !proot.endsWith("/")) {
302302
proot = proot + "/";
303303
}
304304
String root = context.root + proot;
@@ -353,7 +353,7 @@ public void close() {
353353
}
354354

355355

356-
private static class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {
356+
private static final class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {
357357

358358
private NameClassPairEnumeration(SimpleNamingContext context, String root) throws NamingException {
359359
super(context, root);
@@ -366,7 +366,7 @@ protected NameClassPair createObject(String strippedName, Object obj) {
366366
}
367367

368368

369-
private static class BindingEnumeration extends AbstractNamingEnumeration<Binding> {
369+
private static final class BindingEnumeration extends AbstractNamingEnumeration<Binding> {
370370

371371
private BindingEnumeration(SimpleNamingContext context, String root) throws NamingException {
372372
super(context, root);

spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ else if (size() == targetCapacity && this.buffers.getFirst().length == targetCap
292292
}
293293

294294
/**
295-
* Create a new buffer and store it in the LinkedList
295+
* Create a new buffer and store it in the LinkedList.
296296
* <p>Adds a new buffer that can store at least {@code minCapacity} bytes.
297297
*/
298298
private void addBuffer(int minCapacity) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -64,10 +64,10 @@ protected RootBeanDefinition createContainerFactory(String factoryId, Element co
6464

6565
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
6666
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
67-
if (!"".equals(containerClass)) {
68-
return null; // Not supported
67+
if (StringUtils.hasLength(containerClass)) {
68+
return null; // not supported
6969
}
70-
else if ("".equals(containerType) || containerType.startsWith("default")) {
70+
else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
7171
factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory");
7272
}
7373
else if (containerType.startsWith("simple")) {
@@ -91,10 +91,10 @@ protected RootBeanDefinition createContainer(Element containerEle, Element liste
9191

9292
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
9393
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
94-
if (!"".equals(containerClass)) {
94+
if (StringUtils.hasLength(containerClass)) {
9595
containerDef.setBeanClassName(containerClass);
9696
}
97-
else if ("".equals(containerType) || containerType.startsWith("default")) {
97+
else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
9898
containerDef.setBeanClassName("org.springframework.jms.listener.DefaultMessageListenerContainer");
9999
}
100100
else if (containerType.startsWith("simple")) {

spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -55,7 +55,7 @@ public class MutablePersistenceUnitInfo implements SmartPersistenceUnitInfo {
5555

5656
private final List<String> mappingFileNames = new LinkedList<String>();
5757

58-
private List<URL> jarFileUrls = new LinkedList<URL>();
58+
private final List<URL> jarFileUrls = new LinkedList<URL>();
5959

6060
private URL persistenceUnitRootUrl;
6161

0 commit comments

Comments
 (0)