提交 9895e44d 编写于 作者: J Juergen Hoeller

Polishing

上级 643a68f8
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,7 +31,6 @@ import java.util.Random; ...@@ -31,7 +31,6 @@ import java.util.Random;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.MimeType.SpecificityComparator;
/** /**
* Miscellaneous {@link MimeType} utility methods. * Miscellaneous {@link MimeType} utility methods.
...@@ -52,7 +51,7 @@ public abstract class MimeTypeUtils { ...@@ -52,7 +51,7 @@ public abstract class MimeTypeUtils {
/** /**
* Comparator used by {@link #sortBySpecificity(List)}. * Comparator used by {@link #sortBySpecificity(List)}.
*/ */
public static final Comparator<MimeType> SPECIFICITY_COMPARATOR = new SpecificityComparator<>(); public static final Comparator<MimeType> SPECIFICITY_COMPARATOR = new MimeType.SpecificityComparator<>();
/** /**
* Public constant mime type that includes all media ranges (i.e. "&#42;/&#42;"). * Public constant mime type that includes all media ranges (i.e. "&#42;/&#42;").
...@@ -154,10 +153,10 @@ public abstract class MimeTypeUtils { ...@@ -154,10 +153,10 @@ public abstract class MimeTypeUtils {
*/ */
public static final String TEXT_XML_VALUE = "text/xml"; public static final String TEXT_XML_VALUE = "text/xml";
@Nullable @Nullable
private static volatile Random random; private static volatile Random random;
static { static {
ALL = MimeType.valueOf(ALL_VALUE); ALL = MimeType.valueOf(ALL_VALUE);
APPLICATION_JSON = MimeType.valueOf(APPLICATION_JSON_VALUE); APPLICATION_JSON = MimeType.valueOf(APPLICATION_JSON_VALUE);
...@@ -263,6 +262,7 @@ public abstract class MimeTypeUtils { ...@@ -263,6 +262,7 @@ public abstract class MimeTypeUtils {
.map(MimeTypeUtils::parseMimeType).collect(Collectors.toList()); .map(MimeTypeUtils::parseMimeType).collect(Collectors.toList());
} }
/** /**
* Tokenize the given comma-separated string of {@code MimeType} objects * Tokenize the given comma-separated string of {@code MimeType} objects
* into a {@code List<String>}. Unlike simple tokenization by ",", this * into a {@code List<String>}. Unlike simple tokenization by ",", this
...@@ -318,7 +318,6 @@ public abstract class MimeTypeUtils { ...@@ -318,7 +318,6 @@ public abstract class MimeTypeUtils {
return builder.toString(); return builder.toString();
} }
/** /**
* Sorts the given list of {@code MimeType} objects by specificity. * Sorts the given list of {@code MimeType} objects by specificity.
* <p>Given two mime types: * <p>Given two mime types:
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -47,7 +47,7 @@ public class InlineMap extends SpelNodeImpl { ...@@ -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. * 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. * This will speed up later getValue calls and reduce the amount of garbage created.
*/ */
...@@ -70,14 +70,14 @@ public class InlineMap extends SpelNodeImpl { ...@@ -70,14 +70,14 @@ public class InlineMap extends SpelNodeImpl {
break; break;
} }
} }
else if (!((c%2)==0 && (child instanceof PropertyOrFieldReference))) { else if (!(c % 2 == 0 && child instanceof PropertyOrFieldReference)) {
isConstant = false; isConstant = false;
break; break;
} }
} }
} }
if (isConstant) { if (isConstant) {
Map<Object,Object> constantMap = new LinkedHashMap<>(); Map<Object, Object> constantMap = new LinkedHashMap<>();
int childCount = getChildCount(); int childCount = getChildCount();
for (int c = 0; c < childCount; c++) { for (int c = 0; c < childCount; c++) {
SpelNode keyChild = getChild(c++); SpelNode keyChild = getChild(c++);
...@@ -159,9 +159,9 @@ public class InlineMap extends SpelNodeImpl { ...@@ -159,9 +159,9 @@ public class InlineMap extends SpelNodeImpl {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Nullable @Nullable
public Map<Object,Object> getConstantValue() { public Map<Object, Object> getConstantValue() {
Assert.state(this.constant != null, "No constant"); Assert.state(this.constant != null, "No constant");
return (Map<Object,Object>) this.constant.getValue(); return (Map<Object, Object>) this.constant.getValue();
} }
} }
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,8 +24,8 @@ import org.springframework.lang.Nullable; ...@@ -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 * 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 * value. Passing around value references rather than the values themselves can avoid
* incorrect duplication of operand evaluation. For example in 'list[index++]++' without a * incorrect duplication of operand evaluation. For example in 'list[index++]++' without
* value reference for 'list[index++]' it would be necessary to evaluate list[index++] * 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 * twice (once to get the value, once to determine where the value goes) and that would
* double increment index. * double increment index.
* *
...@@ -103,7 +103,8 @@ public interface ValueRef { ...@@ -103,7 +103,8 @@ public interface ValueRef {
@Override @Override
public void setValue(@Nullable Object newValue) { 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 @Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册