diff --git a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java index 52cdb75dfd867f5c499a3eb2711f4f7f5fbdaa71..6bca9156781c7aab1c7ba10b4fc6d835d613612e 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java @@ -16,8 +16,6 @@ package org.springframework.context.annotation; -import java.util.Objects; - import org.springframework.core.type.AnnotationMetadata; import org.springframework.lang.Nullable; @@ -100,7 +98,7 @@ public interface DeferredImportSelector extends ImportSelector { } @Override - public boolean equals(Object other) { + public boolean equals(@Nullable Object other) { if (this == other) { return true; } @@ -108,13 +106,17 @@ public interface DeferredImportSelector extends ImportSelector { return false; } Entry entry = (Entry) other; - return (Objects.equals(this.metadata, entry.metadata) && - Objects.equals(this.importClassName, entry.importClassName)); + return (this.metadata.equals(entry.metadata) && this.importClassName.equals(entry.importClassName)); } @Override public int hashCode() { - return Objects.hash(this.metadata, this.importClassName); + return (this.metadata.hashCode() * 31 + this.importClassName.hashCode()); + } + + @Override + public String toString() { + return this.importClassName; } } } diff --git a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java index dc00e2ded28de71b0bb79423987f0cf26335b4c3..8b5dc4354d85006793003770a6b8523c7d14fc71 100644 --- a/spring-core/src/main/java/org/springframework/util/unit/DataUnit.java +++ b/spring-core/src/main/java/org/springframework/util/unit/DataUnit.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. @@ -16,38 +16,53 @@ package org.springframework.util.unit; -import java.util.Objects; - /** - * A standard set of data size units. + * A standard set of {@link DataSize} units. + * + *

The unit prefixes used in this class are + * binary prefixes + * indicating multiplication by powers of 2. The following table displays the + * enum constants defined in this class and corresponding values. + * + *

+ * + * + * + * + * + * + * + *
ConstantData SizePower of 2Size in Bytes
{@link #BYTES}1B2^01
{@link #KILOBYTES}1KB2^101,024
{@link #MEGABYTES}1MB2^201,048,576
{@link #GIGABYTES}1GB2^301,073,741,824
{@link #TERABYTES}1TB2^401,099,511,627,776
* * @author Stephane Nicoll + * @author Sam Brannen * @since 5.1 + * @see DataSize */ public enum DataUnit { /** - * Bytes. + * Bytes, represented by suffix {@code B}. */ BYTES("B", DataSize.ofBytes(1)), /** - * Kilobytes. + * Kilobytes, represented by suffix {@code KB}. */ KILOBYTES("KB", DataSize.ofKilobytes(1)), /** - * Megabytes. + * Megabytes, represented by suffix {@code MB}. */ MEGABYTES("MB", DataSize.ofMegabytes(1)), /** - * Gigabytes. + * Gigabytes, represented by suffix {@code GB}. */ GIGABYTES("GB", DataSize.ofGigabytes(1)), /** - * Terabytes. + * Terabytes, represented by suffix {@code TB}. */ TERABYTES("TB", DataSize.ofTerabytes(1)); @@ -68,18 +83,18 @@ public enum DataUnit { /** * Return the {@link DataUnit} matching the specified {@code suffix}. - * @param suffix one of the standard suffix + * @param suffix one of the standard suffixes * @return the {@link DataUnit} matching the specified {@code suffix} - * @throws IllegalArgumentException if the suffix does not match any - * of this enum's constants + * @throws IllegalArgumentException if the suffix does not match the suffix + * of any of this enum's constants */ public static DataUnit fromSuffix(String suffix) { for (DataUnit candidate : values()) { - if (Objects.equals(candidate.suffix, suffix)) { + if (candidate.suffix.equals(suffix)) { return candidate; } } - throw new IllegalArgumentException("Unknown unit '" + suffix + "'"); + throw new IllegalArgumentException("Unknown data unit suffix '" + suffix + "'"); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java index d3585c82cf3fd134b5bc4da97260f4ebcaaf3c09..dd30f7695947c2c2dbc264d237e85fe5dff4b3c7 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java @@ -560,7 +560,6 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati } return map; } - } } diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java index 1279d6c4abd2644ee8afa07018149c392107e042..44fc6c641f98b4793764e40a8d6cace1e28e57aa 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.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. @@ -40,6 +40,7 @@ import static org.mockito.BDDMockito.*; * Mock object based tests for TransactionInterceptor. * * @author Rod Johnson + * @author Juergen Hoeller * @since 16.03.2003 */ public class TransactionInterceptorTests extends AbstractTransactionAspectTests { @@ -49,7 +50,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests @Override - protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) throws Exception { + protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) { TransactionInterceptor ti = new TransactionInterceptor(); ti.setTransactionManager(ptm); ti.setTransactionAttributeSources(tas);