Polishing
This commit is contained in:
@@ -93,14 +93,8 @@ public abstract class AttributeAccessorSupport implements AttributeAccessor, Ser
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AttributeAccessorSupport)) {
|
||||
return false;
|
||||
}
|
||||
AttributeAccessorSupport that = (AttributeAccessorSupport) other;
|
||||
return this.attributes.equals(that.attributes);
|
||||
return (this == other || (other instanceof AttributeAccessorSupport &&
|
||||
this.attributes.equals(((AttributeAccessorSupport) other).attributes)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,9 +66,9 @@ public abstract class ParameterizedTypeReference<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof ParameterizedTypeReference &&
|
||||
this.type.equals(((ParameterizedTypeReference<?>) obj).type)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof ParameterizedTypeReference &&
|
||||
this.type.equals(((ParameterizedTypeReference<?>) other).type)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -164,12 +164,10 @@ public class ReactiveAdapterRegistry {
|
||||
/**
|
||||
* Return a shared default {@code ReactiveAdapterRegistry} instance, lazily
|
||||
* building it once needed.
|
||||
*
|
||||
* <p><b>NOTE:</b> We highly recommend passing a long-lived, pre-configured
|
||||
* {@code ReactiveAdapterRegistry} instance for customization purposes.
|
||||
* This accessor is only meant as a fallback for code paths that want to
|
||||
* fall back on a default instance if one isn't provided.
|
||||
*
|
||||
* @return the shared {@code ReactiveAdapterRegistry} instance (never {@code null})
|
||||
* @since 5.0.2
|
||||
*/
|
||||
@@ -191,7 +189,6 @@ public class ReactiveAdapterRegistry {
|
||||
private static class ReactorRegistrar {
|
||||
|
||||
void registerAdapters(ReactiveAdapterRegistry registry) {
|
||||
|
||||
// Register Flux and Mono before Publisher...
|
||||
|
||||
registry.registerReactiveType(
|
||||
@@ -280,7 +277,6 @@ public class ReactiveAdapterRegistry {
|
||||
private static class ReactorJdkFlowAdapterRegistrar {
|
||||
|
||||
void registerAdapter(ReactiveAdapterRegistry registry) throws Exception {
|
||||
|
||||
// TODO: remove reflection when build requires JDK 9+
|
||||
|
||||
String publisherName = "java.util.concurrent.Flow.Publisher";
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -31,10 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Phillip Webb
|
||||
* @since 5.1
|
||||
*/
|
||||
final class ProfilesParser {
|
||||
|
||||
private ProfilesParser() {
|
||||
}
|
||||
abstract class ProfilesParser {
|
||||
|
||||
static Profiles parse(String... expressions) {
|
||||
Assert.notEmpty(expressions, "Must specify at least one profile");
|
||||
@@ -46,8 +44,7 @@ final class ProfilesParser {
|
||||
}
|
||||
|
||||
private static Profiles parseExpression(String expression) {
|
||||
Assert.hasText(expression, () ->
|
||||
"Invalid profile expression [" + expression + "]: must contain text");
|
||||
Assert.hasText(expression, () -> "Invalid profile expression [" + expression + "]: must contain text");
|
||||
StringTokenizer tokens = new StringTokenizer(expression, "()&|!", true);
|
||||
return parseTokens(expression, tokens);
|
||||
}
|
||||
@@ -88,8 +85,7 @@ final class ProfilesParser {
|
||||
return merge(expression, elements, operator);
|
||||
}
|
||||
|
||||
private static Profiles merge(String expression, List<Profiles> elements,
|
||||
Operator operator) {
|
||||
private static Profiles merge(String expression, List<Profiles> elements, @Nullable Operator operator) {
|
||||
assertWellFormed(expression, !elements.isEmpty());
|
||||
if (elements.size() == 1) {
|
||||
return elements.get(0);
|
||||
@@ -99,18 +95,15 @@ final class ProfilesParser {
|
||||
}
|
||||
|
||||
private static void assertWellFormed(String expression, boolean wellFormed) {
|
||||
Assert.isTrue(wellFormed,
|
||||
() -> "Malformed profile expression [" + expression + "]");
|
||||
Assert.isTrue(wellFormed, () -> "Malformed profile expression [" + expression + "]");
|
||||
}
|
||||
|
||||
private static Profiles or(Profiles... profiles) {
|
||||
return activeProfile -> Arrays.stream(profiles).anyMatch(
|
||||
isMatch(activeProfile));
|
||||
return activeProfile -> Arrays.stream(profiles).anyMatch(isMatch(activeProfile));
|
||||
}
|
||||
|
||||
private static Profiles and(Profiles... profiles) {
|
||||
return activeProfile -> Arrays.stream(profiles).allMatch(
|
||||
isMatch(activeProfile));
|
||||
return activeProfile -> Arrays.stream(profiles).allMatch(isMatch(activeProfile));
|
||||
}
|
||||
|
||||
private static Profiles not(Profiles profiles) {
|
||||
@@ -125,10 +118,9 @@ final class ProfilesParser {
|
||||
return profiles -> profiles.matches(activeProfile);
|
||||
}
|
||||
|
||||
private enum Operator {
|
||||
AND,
|
||||
OR
|
||||
}
|
||||
|
||||
private enum Operator {AND, OR}
|
||||
|
||||
|
||||
private static class ParsedProfiles implements Profiles {
|
||||
|
||||
@@ -155,7 +147,6 @@ final class ProfilesParser {
|
||||
public String toString() {
|
||||
return StringUtils.arrayToDelimitedString(this.expressions, " or ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ public abstract class PropertySource<T> {
|
||||
* <p>No properties other than {@code name} are evaluated.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof PropertySource &&
|
||||
ObjectUtils.nullSafeEquals(this.name, ((PropertySource<?>) obj).name)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof PropertySource &&
|
||||
ObjectUtils.nullSafeEquals(this.name, ((PropertySource<?>) other).name)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -209,23 +209,14 @@ public abstract class AbstractResource implements Resource {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This implementation returns the description of this resource.
|
||||
* @see #getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation compares description strings.
|
||||
* @see #getDescription()
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof Resource && ((Resource) obj).getDescription().equals(getDescription())));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof Resource &&
|
||||
((Resource) other).getDescription().equals(getDescription())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,4 +228,13 @@ public abstract class AbstractResource implements Resource {
|
||||
return getDescription().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation returns the description of this resource.
|
||||
* @see #getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -115,9 +115,9 @@ public class ByteArrayResource extends AbstractResource {
|
||||
* @see java.util.Arrays#equals(byte[], byte[])
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof ByteArrayResource && Arrays.equals(((ByteArrayResource) obj).byteArray, this.byteArray)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof ByteArrayResource &&
|
||||
Arrays.equals(((ByteArrayResource) other).byteArray, this.byteArray)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -244,17 +244,17 @@ public class ClassPathResource extends AbstractFileResolvingResource {
|
||||
* This implementation compares the underlying class path locations.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ClassPathResource) {
|
||||
ClassPathResource otherRes = (ClassPathResource) obj;
|
||||
return (this.path.equals(otherRes.path) &&
|
||||
ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
|
||||
ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
|
||||
if (!(other instanceof ClassPathResource)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
ClassPathResource otherRes = (ClassPathResource) other;
|
||||
return (this.path.equals(otherRes.path) &&
|
||||
ObjectUtils.nullSafeEquals(this.classLoader, otherRes.classLoader) &&
|
||||
ObjectUtils.nullSafeEquals(this.clazz, otherRes.clazz));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -72,9 +72,9 @@ public class DescriptiveResource extends AbstractResource {
|
||||
* This implementation compares the underlying description String.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof DescriptiveResource && ((DescriptiveResource) obj).description.equals(this.description)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof DescriptiveResource &&
|
||||
((DescriptiveResource) other).description.equals(this.description)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -282,9 +282,9 @@ public class FileSystemResource extends AbstractResource implements WritableReso
|
||||
* This implementation compares the underlying File references.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof FileSystemResource &&
|
||||
this.path.equals(((FileSystemResource) other).path)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -115,9 +115,9 @@ public class InputStreamResource extends AbstractResource {
|
||||
* This implementation compares the underlying InputStream.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof InputStreamResource &&
|
||||
((InputStreamResource) other).inputStream.equals(this.inputStream)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,9 +274,9 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
* This implementation compares the underlying Path references.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj ||
|
||||
(obj instanceof PathResource && this.path.equals(((PathResource) obj).path)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof PathResource &&
|
||||
this.path.equals(((PathResource) other).path)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -261,9 +261,9 @@ public class UrlResource extends AbstractFileResolvingResource {
|
||||
* This implementation compares the underlying URL references.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this ||
|
||||
(obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof UrlResource &&
|
||||
this.cleanedUrl.equals(((UrlResource) other).cleanedUrl)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -125,8 +125,9 @@ public class VfsResource extends AbstractResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj == this || (obj instanceof VfsResource && this.resource.equals(((VfsResource) obj).resource)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof VfsResource &&
|
||||
this.resource.equals(((VfsResource) other).resource)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,22 +57,22 @@ public interface DataBuffer {
|
||||
DataBufferFactory factory();
|
||||
|
||||
/**
|
||||
* Return the index of the first byte in this buffer that matches the given
|
||||
* predicate.
|
||||
* Return the index of the first byte in this buffer that matches
|
||||
* the given predicate.
|
||||
* @param predicate the predicate to match
|
||||
* @param fromIndex the index to start the search from
|
||||
* @return the index of the first byte that matches {@code predicate}; or {@code -1}
|
||||
* if none match
|
||||
* @return the index of the first byte that matches {@code predicate};
|
||||
* or {@code -1} if none match
|
||||
*/
|
||||
int indexOf(IntPredicate predicate, int fromIndex);
|
||||
|
||||
/**
|
||||
* Return the index of the last byte in this buffer that matches the given
|
||||
* predicate.
|
||||
* Return the index of the last byte in this buffer that matches
|
||||
* the given predicate.
|
||||
* @param predicate the predicate to match
|
||||
* @param fromIndex the index to start the search from
|
||||
* @return the index of the last byte that matches {@code predicate}; or {@code -1}
|
||||
* if none match
|
||||
* @return the index of the last byte that matches {@code predicate};
|
||||
* or {@code -1} if none match
|
||||
*/
|
||||
int lastIndexOf(IntPredicate predicate, int fromIndex);
|
||||
|
||||
@@ -97,9 +97,10 @@ public interface DataBuffer {
|
||||
int capacity();
|
||||
|
||||
/**
|
||||
* Sets the number of bytes that this buffer can contain. If the new capacity is lower than
|
||||
* the current capacity, the contents of this buffer will be truncated. If the new capacity
|
||||
* is higher than the current capacity, it will be expanded.
|
||||
* Set the number of bytes that this buffer can contain.
|
||||
* <p>If the new capacity is lower than the current capacity, the contents
|
||||
* of this buffer will be truncated. If the new capacity is higher than
|
||||
* the current capacity, it will be expanded.
|
||||
* @param capacity the new capacity
|
||||
* @return this buffer
|
||||
*/
|
||||
@@ -116,8 +117,8 @@ public interface DataBuffer {
|
||||
* Set the position from which this buffer will read.
|
||||
* @param readPosition the new read position
|
||||
* @return this buffer
|
||||
* @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0 or greater than
|
||||
* {@link #writePosition()}
|
||||
* @throws IndexOutOfBoundsException if {@code readPosition} is smaller than 0
|
||||
* or greater than {@link #writePosition()}
|
||||
* @since 5.0.1
|
||||
*/
|
||||
DataBuffer readPosition(int readPosition);
|
||||
|
||||
@@ -27,14 +27,13 @@ import java.util.function.IntPredicate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link DataBuffer} interface that uses a
|
||||
* {@link ByteBuffer} internally. with separate read and write positions.
|
||||
* Constructed using the {@link DefaultDataBufferFactory}.
|
||||
*
|
||||
* <p>Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes (i.e. Servlet)
|
||||
* do not require Netty on the classpath.
|
||||
* <p>Inspired by Netty's {@code ByteBuf}. Introduced so that non-Netty runtimes
|
||||
* (i.e. Servlet) do not require Netty on the classpath.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
@@ -52,32 +51,29 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
|
||||
private ByteBuffer byteBuffer;
|
||||
|
||||
private int capacity;
|
||||
|
||||
private int readPosition;
|
||||
|
||||
private int writePosition;
|
||||
|
||||
private int capacity;
|
||||
|
||||
private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||
Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
|
||||
Assert.notNull(byteBuffer, "'byteBuffer' must not be null");
|
||||
|
||||
Assert.notNull(dataBufferFactory, "DefaultDataBufferFactory must not be null");
|
||||
Assert.notNull(byteBuffer, "ByteBuffer must not be null");
|
||||
this.dataBufferFactory = dataBufferFactory;
|
||||
ByteBuffer slice = byteBuffer.slice();
|
||||
this.byteBuffer = slice;
|
||||
this.capacity = slice.remaining();
|
||||
}
|
||||
|
||||
static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory,
|
||||
ByteBuffer byteBuffer) {
|
||||
|
||||
static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||
DefaultDataBuffer dataBuffer = new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
||||
dataBuffer.writePosition(byteBuffer.remaining());
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory,
|
||||
ByteBuffer byteBuffer) {
|
||||
static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer) {
|
||||
return new DefaultDataBuffer(dataBufferFactory, byteBuffer);
|
||||
}
|
||||
|
||||
@@ -95,6 +91,7 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
this.capacity = byteBuffer.remaining();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DefaultDataBufferFactory factory() {
|
||||
return this.dataBufferFactory;
|
||||
@@ -414,17 +411,17 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DefaultDataBuffer)) {
|
||||
if (!(other instanceof DefaultDataBuffer)) {
|
||||
return false;
|
||||
}
|
||||
DefaultDataBuffer other = (DefaultDataBuffer) obj;
|
||||
return (this.readPosition == other.readPosition &&
|
||||
this.writePosition == other.writePosition &&
|
||||
this.byteBuffer.equals(other.byteBuffer));
|
||||
DefaultDataBuffer otherBuffer = (DefaultDataBuffer) other;
|
||||
return (this.readPosition == otherBuffer.readPosition &&
|
||||
this.writePosition == otherBuffer.writePosition &&
|
||||
this.byteBuffer.equals(otherBuffer.byteBuffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,10 +431,11 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("DefaultDataBuffer (r: %d, w %d, c %d)", this.readPosition,
|
||||
this.writePosition, this.capacity);
|
||||
return String.format("DefaultDataBuffer (r: %d, w %d, c %d)",
|
||||
this.readPosition, this.writePosition, this.capacity);
|
||||
}
|
||||
|
||||
|
||||
private void checkIndex(int index, int length) {
|
||||
assertIndex(index >= 0, "index %d must be >= 0", index);
|
||||
assertIndex(length >= 0, "length %d must be >= 0", index);
|
||||
@@ -452,6 +450,7 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class DefaultDataBufferInputStream extends InputStream {
|
||||
|
||||
@Override
|
||||
@@ -479,7 +478,6 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class DefaultDataBufferOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
@@ -496,16 +494,14 @@ public class DefaultDataBuffer implements DataBuffer {
|
||||
|
||||
private static class SlicedDefaultDataBuffer extends DefaultDataBuffer {
|
||||
|
||||
SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory,
|
||||
int length) {
|
||||
SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length) {
|
||||
super(dataBufferFactory, byteBuffer);
|
||||
writePosition(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultDataBuffer capacity(int newCapacity) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Changing the capacity of a sliced buffer is not supported");
|
||||
throw new UnsupportedOperationException("Changing the capacity of a sliced buffer is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,18 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class NettyDataBuffer implements PooledDataBuffer {
|
||||
|
||||
private final NettyDataBufferFactory dataBufferFactory;
|
||||
|
||||
private final ByteBuf byteBuf;
|
||||
|
||||
private final NettyDataBufferFactory dataBufferFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@code NettyDataBuffer} based on the given {@code ByteBuff}.
|
||||
* @param byteBuf the buffer to base this buffer on
|
||||
*/
|
||||
NettyDataBuffer(ByteBuf byteBuf, NettyDataBufferFactory dataBufferFactory) {
|
||||
Assert.notNull(byteBuf, "'byteBuf' must not be null");
|
||||
Assert.notNull(dataBufferFactory, "'dataBufferFactory' must not be null");
|
||||
|
||||
Assert.notNull(byteBuf, "ByteBuf must not be null");
|
||||
Assert.notNull(dataBufferFactory, "NettyDataBufferFactory must not be null");
|
||||
this.byteBuf = byteBuf;
|
||||
this.dataBufferFactory = dataBufferFactory;
|
||||
}
|
||||
@@ -272,15 +271,9 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof NettyDataBuffer)) {
|
||||
return false;
|
||||
}
|
||||
NettyDataBuffer other = (NettyDataBuffer) obj;
|
||||
return this.byteBuf.equals(other.byteBuf);
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof NettyDataBuffer &&
|
||||
this.byteBuf.equals(((NettyDataBuffer) other).byteBuf)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -839,12 +839,12 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
|
||||
|
||||
@Override
|
||||
public boolean contains(@Nullable Object o) {
|
||||
if (o != null && o instanceof Map.Entry<?, ?>) {
|
||||
if (o instanceof Map.Entry<?, ?>) {
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) o;
|
||||
Reference<K, V> reference = ConcurrentReferenceHashMap.this.getReference(entry.getKey(), Restructure.NEVER);
|
||||
Entry<K, V> other = (reference != null ? reference.get() : null);
|
||||
if (other != null) {
|
||||
return ObjectUtils.nullSafeEquals(entry.getValue(), other.getValue());
|
||||
Entry<K, V> otherEntry = (reference != null ? reference.get() : null);
|
||||
if (otherEntry != null) {
|
||||
return ObjectUtils.nullSafeEquals(otherEntry.getValue(), otherEntry.getValue());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -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.
|
||||
@@ -67,9 +67,9 @@ public class BooleanComparator implements Comparator<Boolean>, Serializable {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj ||
|
||||
(obj instanceof BooleanComparator && (this.trueLow == ((BooleanComparator) obj).trueLow)));
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof BooleanComparator &&
|
||||
this.trueLow == ((BooleanComparator) other).trueLow));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -187,15 +187,9 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof CompoundComparator)) {
|
||||
return false;
|
||||
}
|
||||
CompoundComparator<T> other = (CompoundComparator<T>) obj;
|
||||
return this.comparators.equals(other.comparators);
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof CompoundComparator &&
|
||||
this.comparators.equals(((CompoundComparator<T>) other).comparators)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -108,15 +108,15 @@ public class InvertibleComparator<T> implements Comparator<T>, Serializable {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof InvertibleComparator)) {
|
||||
if (!(other instanceof InvertibleComparator)) {
|
||||
return false;
|
||||
}
|
||||
InvertibleComparator<T> other = (InvertibleComparator<T>) obj;
|
||||
return (this.comparator.equals(other.comparator) && this.ascending == other.ascending);
|
||||
InvertibleComparator<T> otherComp = (InvertibleComparator<T>) other;
|
||||
return (this.comparator.equals(otherComp.comparator) && this.ascending == otherComp.ascending);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -108,15 +108,15 @@ public class NullSafeComparator<T> implements Comparator<T> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof NullSafeComparator)) {
|
||||
if (!(other instanceof NullSafeComparator)) {
|
||||
return false;
|
||||
}
|
||||
NullSafeComparator<T> other = (NullSafeComparator<T>) obj;
|
||||
return (this.nonNullComparator.equals(other.nonNullComparator) && this.nullsLow == other.nullsLow);
|
||||
NullSafeComparator<T> otherComp = (NullSafeComparator<T>) other;
|
||||
return (this.nonNullComparator.equals(otherComp.nonNullComparator) && this.nullsLow == otherComp.nullsLow);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user