From 54e2d63d6f6f4e9467fe4bcba0c83306c6d60ba4 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 19 Jan 2017 21:21:01 +0100 Subject: [PATCH] Polishing --- .../index/IndexedStereotypesProvider.java | 11 ++++------- ...alVariableTableParameterNameDiscoverer.java | 5 ++--- .../PrioritizedParameterNameDiscoverer.java | 18 ++++++++---------- ...ndardReflectionParameterNameDiscoverer.java | 3 ++- .../converter/ConvertingComparator.java | 6 +++--- .../util/InvalidMimeTypeException.java | 5 ++--- .../util/comparator/CompoundComparator.java | 6 +++--- .../org/springframework/http/MediaType.java | 8 ++++---- 8 files changed, 28 insertions(+), 34 deletions(-) diff --git a/spring-context-indexer/src/main/java/org/springframework/context/index/IndexedStereotypesProvider.java b/spring-context-indexer/src/main/java/org/springframework/context/index/IndexedStereotypesProvider.java index f7d6e72b0c5..96d064083c4 100644 --- a/spring-context-indexer/src/main/java/org/springframework/context/index/IndexedStereotypesProvider.java +++ b/spring-context-indexer/src/main/java/org/springframework/context/index/IndexedStereotypesProvider.java @@ -57,19 +57,16 @@ class IndexedStereotypesProvider implements StereotypesProvider { return stereotypes; } - private void collectStereotypesOnAnnotations(Set seen, Set stereotypes, - Element element) { + private void collectStereotypesOnAnnotations(Set seen, Set stereotypes, Element element) { for (AnnotationMirror annotation : this.typeHelper.getAllAnnotationMirrors(element)) { Element next = collectStereotypes(seen, stereotypes, element, annotation); if (next != null) { collectStereotypesOnAnnotations(seen, stereotypes, next); } } - } - private void collectStereotypesOnTypes(Set seen, Set stereotypes, - Element type) { + private void collectStereotypesOnTypes(Set seen, Set stereotypes, Element type) { if (!seen.contains(type)) { seen.add(type); if (isAnnotatedWithIndexed(type)) { @@ -84,8 +81,8 @@ class IndexedStereotypesProvider implements StereotypesProvider { } } - private Element collectStereotypes(Set seen, Set stereotypes, - Element element, AnnotationMirror annotation) { + private Element collectStereotypes(Set seen, Set stereotypes, Element element, + AnnotationMirror annotation) { if (isIndexedAnnotation(annotation)) { stereotypes.add(this.typeHelper.getType(element)); diff --git a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java index 767be3046ef..2f88ca8cc38 100644 --- a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -60,8 +60,7 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD private static final Map NO_DEBUG_INFO_MAP = Collections.emptyMap(); // the cache uses a nested index (value is a map) to keep the top level cache relatively small in size - private final Map, Map> parameterNamesCache = - new ConcurrentHashMap<>(32); + private final Map, Map> parameterNamesCache = new ConcurrentHashMap<>(32); @Override diff --git a/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java index 535118be7d6..0aa80aa9594 100644 --- a/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -22,12 +22,11 @@ import java.util.LinkedList; import java.util.List; /** - * ParameterNameDiscoverer implementation that tries several ParameterNameDiscoverers - * in succession. Those added first in the {@code addDiscoverer} method have - * highest priority. If one returns {@code null}, the next will be tried. + * {@link ParameterNameDiscoverer} implementation that tries several discoverer + * delegates in succession. Those added first in the {@code addDiscoverer} method + * have highest priority. If one returns {@code null}, the next will be tried. * - *

The default behavior is always to return {@code null} - * if no discoverer matches. + *

The default behavior is to return {@code null} if no discoverer matches. * * @author Rod Johnson * @author Juergen Hoeller @@ -35,13 +34,12 @@ import java.util.List; */ public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscoverer { - private final List parameterNameDiscoverers = - new LinkedList<>(); + private final List parameterNameDiscoverers = new LinkedList<>(); /** - * Add a further ParameterNameDiscoverer to the list of discoverers - * that this PrioritizedParameterNameDiscoverer checks. + * Add a further {@link ParameterNameDiscoverer} delegate to the list of + * discoverers that this {@code PrioritizedParameterNameDiscoverer} checks. */ public void addDiscoverer(ParameterNameDiscoverer pnd) { this.parameterNameDiscoverers.add(pnd); diff --git a/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java index f263681aed4..a06eeb6354e 100644 --- a/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -26,6 +26,7 @@ import java.lang.reflect.Parameter; * * @author Juergen Hoeller * @since 4.0 + * @see java.lang.reflect.Method#getParameters() * @see java.lang.reflect.Parameter#getName() */ public class StandardReflectionParameterNameDiscoverer implements ParameterNameDiscoverer { diff --git a/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java b/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java index 19e128c8848..716f8346032 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java +++ b/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -35,9 +35,9 @@ import org.springframework.util.comparator.ComparableComparator; */ public class ConvertingComparator implements Comparator { - private Comparator comparator; + private final Comparator comparator; - private Converter converter; + private final Converter converter; /** diff --git a/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java b/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java index 7eff662059c..983bdb03fa6 100644 --- a/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java +++ b/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2017 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. @@ -27,7 +27,7 @@ package org.springframework.util; @SuppressWarnings("serial") public class InvalidMimeTypeException extends IllegalArgumentException { - private String mimeType; + private final String mimeType; /** @@ -38,7 +38,6 @@ public class InvalidMimeTypeException extends IllegalArgumentException { public InvalidMimeTypeException(String mimeType, String message) { super("Invalid mime type \"" + mimeType + "\": " + message); this.mimeType = mimeType; - } diff --git a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java index cf784ebda30..b027fb287c8 100644 --- a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java +++ b/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -37,7 +37,7 @@ import org.springframework.util.Assert; * @author Juergen Hoeller * @since 1.2.2 */ -@SuppressWarnings({ "serial", "rawtypes" }) +@SuppressWarnings({"serial", "rawtypes"}) public class CompoundComparator implements Comparator, Serializable { private final List comparators; @@ -64,7 +64,7 @@ public class CompoundComparator implements Comparator, Serializable { Assert.notNull(comparators, "Comparators must not be null"); this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { - this.addComparator(comparator); + addComparator(comparator); } } diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 8387f427ec0..c44140483d6 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -254,27 +254,27 @@ public class MediaType extends MimeType implements Serializable { /** * Public constant media type for {@code application/problem+json}. - * @since 5.0.0 + * @since 5.0 * @see Problem Details for HTTP APIs, 6.1. application/problem+json */ public final static MediaType APPLICATION_PROBLEM_JSON; /** * A String equivalent of {@link MediaType#APPLICATION_PROBLEM_JSON}. - * @since 5.0.0 + * @since 5.0 */ public final static String APPLICATION_PROBLEM_JSON_VALUE = "application/problem+json"; /** * Public constant media type for {@code application/problem+xml}. - * @since 5.0.0 + * @since 5.0 * @see Problem Details for HTTP APIs, 6.2. application/problem+xml */ public final static MediaType APPLICATION_PROBLEM_XML; /** * A String equivalent of {@link MediaType#APPLICATION_PROBLEM_XML}. - * @since 5.0.0 + * @since 5.0 */ public final static String APPLICATION_PROBLEM_XML_VALUE = "application/problem+xml";