From 9895e44d7309295302859f8ad4328e8ea5d4fcf5 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 16:03:24 +0100 Subject: [PATCH] Polishing --- .../java/org/springframework/util/MimeTypeUtils.java | 9 ++++----- .../expression/spel/ast/InlineMap.java | 12 ++++++------ .../expression/spel/ast/ValueRef.java | 9 +++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index d09ee8c4a2..93653c3b18 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -31,7 +31,6 @@ import java.util.Random; import java.util.stream.Collectors; import org.springframework.lang.Nullable; -import org.springframework.util.MimeType.SpecificityComparator; /** * Miscellaneous {@link MimeType} utility methods. @@ -52,7 +51,7 @@ public abstract class MimeTypeUtils { /** * Comparator used by {@link #sortBySpecificity(List)}. */ - public static final Comparator SPECIFICITY_COMPARATOR = new SpecificityComparator<>(); + public static final Comparator SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>(); /** * Public constant mime type that includes all media ranges (i.e. "*/*"). @@ -154,10 +153,10 @@ public abstract class MimeTypeUtils { */ public static final String TEXT_XML_VALUE = "text/xml"; + @Nullable private static volatile Random random; - static { ALL = MimeType.valueOf(ALL_VALUE); APPLICATION_JSON = MimeType.valueOf(APPLICATION_JSON_VALUE); @@ -263,6 +262,7 @@ public abstract class MimeTypeUtils { .map(MimeTypeUtils::parseMimeType).collect(Collectors.toList()); } + /** * Tokenize the given comma-separated string of {@code MimeType} objects * into a {@code List}. Unlike simple tokenization by ",", this @@ -318,7 +318,6 @@ public abstract class MimeTypeUtils { return builder.toString(); } - /** * Sorts the given list of {@code MimeType} objects by specificity. *

Given two mime types: diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java index b29d124930..4110add6f7 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -47,7 +47,7 @@ public class InlineMap extends SpelNodeImpl { /** - * If all the components of the list are constants, or lists/maps that themselves + * If all the components of the map are constants, or lists/maps that themselves * contain constants, then a constant list can be built to represent this node. * This will speed up later getValue calls and reduce the amount of garbage created. */ @@ -70,14 +70,14 @@ public class InlineMap extends SpelNodeImpl { break; } } - else if (!((c%2)==0 && (child instanceof PropertyOrFieldReference))) { + else if (!(c % 2 == 0 && child instanceof PropertyOrFieldReference)) { isConstant = false; break; } } } if (isConstant) { - Map constantMap = new LinkedHashMap<>(); + Map constantMap = new LinkedHashMap<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { SpelNode keyChild = getChild(c++); @@ -159,9 +159,9 @@ public class InlineMap extends SpelNodeImpl { @SuppressWarnings("unchecked") @Nullable - public Map getConstantValue() { + public Map getConstantValue() { Assert.state(this.constant != null, "No constant"); - return (Map) this.constant.getValue(); + return (Map) this.constant.getValue(); } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ValueRef.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ValueRef.java index 702f0e5c6a..f0c09af997 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ValueRef.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ValueRef.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -24,8 +24,8 @@ import org.springframework.lang.Nullable; /** * Represents a reference to a value. With a reference it is possible to get or set the * value. Passing around value references rather than the values themselves can avoid - * incorrect duplication of operand evaluation. For example in 'list[index++]++' without a - * value reference for 'list[index++]' it would be necessary to evaluate list[index++] + * incorrect duplication of operand evaluation. For example in 'list[index++]++' without + * a value reference for 'list[index++]' it would be necessary to evaluate list[index++] * twice (once to get the value, once to determine where the value goes) and that would * double increment index. * @@ -103,7 +103,8 @@ public interface ValueRef { @Override public void setValue(@Nullable Object newValue) { - throw new SpelEvaluationException(this.node.pos, SpelMessage.NOT_ASSIGNABLE, this.node.toStringAST()); + throw new SpelEvaluationException( + this.node.getStartPosition(), SpelMessage.NOT_ASSIGNABLE, this.node.toStringAST()); } @Override