Skip to content

Commit 2891dc6

Browse files
committed
Polishing
1 parent f744088 commit 2891dc6

File tree

21 files changed

+104
-110
lines changed

21 files changed

+104
-110
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 & 4 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,18 +24,17 @@
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) {
3535
this.beanDefinitionName = beanDefinitionName;
3636
}
3737

38-
3938
@Override
4039
public String toString() {
4140
return "Bean '" + this.beanDefinitionName + "'";

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

Lines changed: 14 additions & 19 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.
@@ -22,23 +22,17 @@
2222

2323
/**
2424
* Simple {@link LinkedList}-based structure for tracking the logical position during
25-
* a parsing process. {@link Entry entries} are added to the LinkedList at
26-
* each point during the parse phase in a reader-specific manner.
25+
* a parsing process. {@link Entry entries} are added to the LinkedList at each point
26+
* during the parse phase in a reader-specific manner.
2727
*
2828
* <p>Calling {@link #toString()} will render a tree-style view of the current logical
29-
* position in the parse phase. This representation is intended for use in
30-
* error messages.
29+
* position in the parse phase. This representation is intended for use in error messages.
3130
*
3231
* @author Rob Harrop
3332
* @since 2.0
3433
*/
3534
public final class ParseState {
3635

37-
/**
38-
* Tab character used when rendering the tree-style representation.
39-
*/
40-
private static final char TAB = '\t';
41-
4236
/**
4337
* Internal {@link LinkedList} storage.
4438
*/
@@ -53,8 +47,8 @@ public ParseState() {
5347
}
5448

5549
/**
56-
* Create a new {@code ParseState} whose {@link LinkedList} is a {@link Object#clone clone}
57-
* of that of the passed in {@code ParseState}.
50+
* Create a new {@code ParseState} whose {@link LinkedList} is a clone
51+
* of the state in the passed in {@code ParseState}.
5852
*/
5953
@SuppressWarnings("unchecked")
6054
private ParseState(ParseState other) {
@@ -99,16 +93,18 @@ public ParseState snapshot() {
9993
*/
10094
@Override
10195
public String toString() {
102-
StringBuilder sb = new StringBuilder();
103-
for (int x = 0; x < this.state.size(); x++) {
104-
if (x > 0) {
96+
StringBuilder sb = new StringBuilder(64);
97+
int i = 0;
98+
for (ParseState.Entry entry : this.state) {
99+
if (i > 0) {
105100
sb.append('\n');
106-
for (int y = 0; y < x; y++) {
107-
sb.append(TAB);
101+
for (int j = 0; j < i; j++) {
102+
sb.append('\t');
108103
}
109104
sb.append("-> ");
110105
}
111-
sb.append(this.state.get(x));
106+
sb.append(entry);
107+
i++;
112108
}
113109
return sb.toString();
114110
}
@@ -118,7 +114,6 @@ public String toString() {
118114
* Marker interface for entries into the {@link ParseState}.
119115
*/
120116
public interface Entry {
121-
122117
}
123118

124119
}

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<>();
41+
private final List<String> typeIdentifiers = new LinkedList<>();
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public Object lookup(String lookupName) throws NameNotFoundException {
123123
if (logger.isDebugEnabled()) {
124124
logger.debug("Static JNDI lookup: [" + name + "]");
125125
}
126-
if ("".equals(name)) {
126+
if (name.isEmpty()) {
127127
return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
128128
}
129129
Object found = this.boundObjects.get(name);
@@ -300,10 +300,10 @@ public Name composeName(Name name, Name prefix) throws NamingException {
300300

301301
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
302302

303-
private Iterator<T> iterator;
303+
private final Iterator<T> iterator;
304304

305305
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
306-
if (!"".equals(proot) && !proot.endsWith("/")) {
306+
if (!proot.isEmpty() && !proot.endsWith("/")) {
307307
proot = proot + "/";
308308
}
309309
String root = context.root + proot;

0 commit comments

Comments
 (0)