@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -74,15 +74,15 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractMediaTypeExpression other = (AbstractMediaTypeExpression) obj;
|
||||
return (this.mediaType.equals(other.mediaType) && this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractMediaTypeExpression otherExpr = (AbstractMediaTypeExpression) other;
|
||||
return (this.mediaType.equals(otherExpr.mediaType) && this.isNegated == otherExpr.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.mvc.condition;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Supports "name=value" style expressions as described in:
|
||||
@@ -92,19 +93,16 @@ abstract class AbstractNameValueExpression<T> implements NameValueExpression<T>
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof AbstractNameValueExpression) {
|
||||
AbstractNameValueExpression<?> other = (AbstractNameValueExpression<?>) obj;
|
||||
String thisName = (isCaseSensitiveName() ? this.name : this.name.toLowerCase());
|
||||
String otherName = (isCaseSensitiveName() ? other.name : other.name.toLowerCase());
|
||||
return (thisName.equalsIgnoreCase(otherName) &&
|
||||
(this.value != null ? this.value.equals(other.value) : other.value == null) &&
|
||||
this.isNegated == other.isNegated);
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
AbstractNameValueExpression<?> that = (AbstractNameValueExpression<?>) other;
|
||||
return ((isCaseSensitiveName() ? this.name.equals(that.name) : this.name.equalsIgnoreCase(that.name)) &&
|
||||
ObjectUtils.nullSafeEquals(this.value, that.value) && this.isNegated == that.isNegated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,15 +55,14 @@ public abstract class AbstractRequestCondition<T extends AbstractRequestConditio
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj != null && getClass() == obj.getClass()) {
|
||||
AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj;
|
||||
return getContent().equals(other.getContent());
|
||||
if (other == null || getClass() != other.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return getContent().equals(((AbstractRequestCondition<?>) other).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition<Composit
|
||||
|
||||
@Override
|
||||
protected Collection<?> getContent() {
|
||||
return (isEmpty()) ? Collections.emptyList() : getConditions();
|
||||
return (!isEmpty() ? getConditions() : Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition<Con
|
||||
*/
|
||||
@Override
|
||||
public ConsumesRequestCondition combine(ConsumesRequestCondition other) {
|
||||
return !other.expressions.isEmpty() ? other : this;
|
||||
return (!other.expressions.isEmpty() ? other : this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,8 +175,8 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
else {
|
||||
result.add("");
|
||||
}
|
||||
return new PatternsRequestCondition(result, this.pathHelper, this.pathMatcher, this.useSuffixPatternMatch,
|
||||
this.useTrailingSlashMatch, this.fileExtensions);
|
||||
return new PatternsRequestCondition(result, this.pathHelper, this.pathMatcher,
|
||||
this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,17 +198,14 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
@Override
|
||||
@Nullable
|
||||
public PatternsRequestCondition getMatchingCondition(HttpServletRequest request) {
|
||||
|
||||
if (this.patterns.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
String lookupPath = this.pathHelper.getLookupPathForRequest(request);
|
||||
List<String> matches = getMatchingPatterns(lookupPath);
|
||||
|
||||
return matches.isEmpty() ? null :
|
||||
new PatternsRequestCondition(matches, this.pathHelper, this.pathMatcher, this.useSuffixPatternMatch,
|
||||
this.useTrailingSlashMatch, this.fileExtensions);
|
||||
return (!matches.isEmpty() ?
|
||||
new PatternsRequestCondition(matches, this.pathHelper, this.pathMatcher,
|
||||
this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractVersionStrategy implements VersionStrategy {
|
||||
private final String prefix;
|
||||
|
||||
public PrefixVersionPathStrategy(String version) {
|
||||
Assert.hasText(version, "'version' must not be empty");
|
||||
Assert.hasText(version, "Version must not be empty");
|
||||
this.prefix = version;
|
||||
}
|
||||
|
||||
|
||||
@@ -239,19 +239,19 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||
|
||||
@Override
|
||||
public int compareTo(ContentChunkInfo other) {
|
||||
return (this.start < other.start ? -1 : (this.start == other.start ? 0 : 1));
|
||||
return Integer.compare(this.start, other.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ContentChunkInfo) {
|
||||
ContentChunkInfo other = (ContentChunkInfo) obj;
|
||||
return (this.start == other.start && this.end == other.end);
|
||||
if (!(other instanceof ContentChunkInfo)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
ContentChunkInfo otherCci = (ContentChunkInfo) other;
|
||||
return (this.start == otherCci.start && this.end == otherCci.end);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
@@ -222,7 +222,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
|
||||
}
|
||||
if (this.resourceLoaderPaths == null) {
|
||||
String resourceLoaderPath = viewConfig.getResourceLoaderPath();
|
||||
setResourceLoaderPath(resourceLoaderPath == null ? DEFAULT_RESOURCE_LOADER_PATH : resourceLoaderPath);
|
||||
setResourceLoaderPath(resourceLoaderPath != null ? resourceLoaderPath : DEFAULT_RESOURCE_LOADER_PATH);
|
||||
}
|
||||
if (this.sharedEngine == null && viewConfig.isSharedEngine() != null) {
|
||||
this.sharedEngine = viewConfig.isSharedEngine();
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HeadersRequestConditionTests {
|
||||
public void headerEquals() {
|
||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("foo"));
|
||||
assertEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("FOO"));
|
||||
assertFalse(new HeadersRequestCondition("foo").equals(new HeadersRequestCondition("bar")));
|
||||
assertNotEquals(new HeadersRequestCondition("foo"), new HeadersRequestCondition("bar"));
|
||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("foo=bar"));
|
||||
assertEquals(new HeadersRequestCondition("foo=bar"), new HeadersRequestCondition("FOO=bar"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user