Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Aug 27, 2020
1 parent 6c977e9 commit b6677cc
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,13 +30,14 @@ public class AdviceEntry implements ParseState.Entry {


/**
* Creates a new instance of the {@link AdviceEntry} class.
* @param kind the kind of advice represented by this entry (before, after, around, etc.)
* Create a new {@code AdviceEntry} instance.
* @param kind the kind of advice represented by this entry (before, after, around)
*/
public AdviceEntry(String kind) {
this.kind = kind;
}


@Override
public String toString() {
return "Advice (" + this.kind + ")";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,13 +30,14 @@ public class AdvisorEntry implements ParseState.Entry {


/**
* Creates a new instance of the {@link AdvisorEntry} class.
* Create a new {@code AdvisorEntry} instance.
* @param name the bean name of the advisor
*/
public AdvisorEntry(String name) {
this.name = name;
}


@Override
public String toString() {
return "Advisor '" + this.name + "'";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ public class AspectEntry implements ParseState.Entry {


/**
* Create a new AspectEntry.
* Create a new {@code AspectEntry} instance.
* @param id the id of the aspect element
* @param ref the bean name referenced by this aspect element
*/
Expand All @@ -43,6 +43,7 @@ public AspectEntry(String id, String ref) {
this.ref = ref;
}


@Override
public String toString() {
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" : "ref='" + this.ref + "'");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,14 +28,16 @@ public class PointcutEntry implements ParseState.Entry {

private final String name;


/**
* Creates a new instance of the {@link PointcutEntry} class.
* Create a new {@code PointcutEntry} instance.
* @param name the bean name of the pointcut
*/
public PointcutEntry(String name) {
this.name = name;
}


@Override
public String toString() {
return "Pointcut '" + this.name + "'";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,11 +24,11 @@
*/
public class BeanEntry implements ParseState.Entry {

private String beanDefinitionName;
private final String beanDefinitionName;


/**
* Creates a new instance of {@link BeanEntry} class.
* Create a new {@code BeanEntry} instance.
* @param beanDefinitionName the name of the associated bean definition
*/
public BeanEntry(String beanDefinitionName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,17 @@

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

/**
* Tab character used when rendering the tree-style representation.
*/
private static final char TAB = '\t';

/**
* Internal {@link Stack} storage.
*/
Expand All @@ -51,7 +45,7 @@ public ParseState() {
}

/**
* Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone}
* Create a new {@code ParseState} whose {@link Stack} is a clone
* of that of the passed in {@code ParseState}.
*/
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -79,7 +73,7 @@ public void pop() {
* {@code null} if the {@link Stack} is empty.
*/
public Entry peek() {
return this.state.empty() ? null : this.state.peek();
return (this.state.empty() ? null : this.state.peek());
}

/**
Expand All @@ -96,16 +90,18 @@ public ParseState snapshot() {
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int x = 0; x < this.state.size(); x++) {
if (x > 0) {
StringBuilder sb = new StringBuilder(64);
int i = 0;
for (ParseState.Entry entry : this.state) {
if (i > 0) {
sb.append('\n');
for (int y = 0; y < x; y++) {
sb.append(TAB);
for (int j = 0; j < i; j++) {
sb.append('\t');
}
sb.append("-> ");
}
sb.append(this.state.get(x));
sb.append(entry);
i++;
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,14 +30,12 @@ public class PropertyEntry implements ParseState.Entry {


/**
* Creates a new instance of the {@link PropertyEntry} class.
* Create a new {@code PropertyEntry} instance.
* @param name the name of the JavaBean property represented by this instance
* @throws IllegalArgumentException if the supplied {@code name} is {@code null}
* or consists wholly of whitespace
*/
public PropertyEntry(String name) {
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Invalid property name '" + name + "'.");
throw new IllegalArgumentException("Invalid property name '" + name + "'");
}
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,16 +26,21 @@
*/
public class QualifierEntry implements ParseState.Entry {

private String typeName;
private final String typeName;


/**
* Create a new {@code QualifierEntry} instance.
* @param typeName the name of the qualifier type
*/
public QualifierEntry(String typeName) {
if (!StringUtils.hasText(typeName)) {
throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'.");
throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'");
}
this.typeName = typeName;
}


@Override
public String toString() {
return "Qualifier '" + this.typeName + "'";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,7 @@ public class ReplaceOverride extends MethodOverride {

private final String methodReplacerBeanName;

private List<String> typeIdentifiers = new LinkedList<String>();
private final List<String> typeIdentifiers = new LinkedList<String>();


/**
Expand Down Expand Up @@ -69,6 +69,7 @@ public void addTypeIdentifier(String identifier) {
this.typeIdentifiers.add(identifier);
}


@Override
public boolean matches(Method method) {
if (!method.getName().equals(getMethodName())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -119,7 +119,7 @@ public Object lookup(String lookupName) throws NameNotFoundException {
if (logger.isDebugEnabled()) {
logger.debug("Static JNDI lookup: [" + name + "]");
}
if ("".equals(name)) {
if (name.isEmpty()) {
return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
}
Object found = this.boundObjects.get(name);
Expand Down Expand Up @@ -293,12 +293,12 @@ public Name composeName(Name name, Name prefix) throws NamingException {
}


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

private Iterator<T> iterator;
private final Iterator<T> iterator;

private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
if (!"".equals(proot) && !proot.endsWith("/")) {
if (!proot.isEmpty() && !proot.endsWith("/")) {
proot = proot + "/";
}
String root = context.root + proot;
Expand Down Expand Up @@ -353,7 +353,7 @@ public void close() {
}


private static class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {
private static final class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {

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


private static class BindingEnumeration extends AbstractNamingEnumeration<Binding> {
private static final class BindingEnumeration extends AbstractNamingEnumeration<Binding> {

private BindingEnumeration(SimpleNamingContext context, String root) throws NamingException {
super(context, root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ else if (size() == targetCapacity && this.buffers.getFirst().length == targetCap
}

/**
* Create a new buffer and store it in the LinkedList
* Create a new buffer and store it in the LinkedList.
* <p>Adds a new buffer that can store at least {@code minCapacity} bytes.
*/
private void addBuffer(int minCapacity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,10 +64,10 @@ protected RootBeanDefinition createContainerFactory(String factoryId, Element co

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

String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
if (!"".equals(containerClass)) {
if (StringUtils.hasLength(containerClass)) {
containerDef.setBeanClassName(containerClass);
}
else if ("".equals(containerType) || containerType.startsWith("default")) {
else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
containerDef.setBeanClassName("org.springframework.jms.listener.DefaultMessageListenerContainer");
}
else if (containerType.startsWith("simple")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,7 +55,7 @@ public class MutablePersistenceUnitInfo implements SmartPersistenceUnitInfo {

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

private List<URL> jarFileUrls = new LinkedList<URL>();
private final List<URL> jarFileUrls = new LinkedList<URL>();

private URL persistenceUnitRootUrl;

Expand Down

0 comments on commit b6677cc

Please sign in to comment.