Skip to content

Commit b4cf471

Browse files
committed
Polishing
1 parent 8275114 commit b4cf471

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

spring-context/src/main/java/org/springframework/context/annotation/DeferredImportSelector.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.context.annotation;
1818

19-
import java.util.Objects;
20-
2119
import org.springframework.core.type.AnnotationMetadata;
2220
import org.springframework.lang.Nullable;
2321

@@ -100,21 +98,25 @@ public String getImportClassName() {
10098
}
10199

102100
@Override
103-
public boolean equals(Object other) {
101+
public boolean equals(@Nullable Object other) {
104102
if (this == other) {
105103
return true;
106104
}
107105
if (other == null || getClass() != other.getClass()) {
108106
return false;
109107
}
110108
Entry entry = (Entry) other;
111-
return (Objects.equals(this.metadata, entry.metadata) &&
112-
Objects.equals(this.importClassName, entry.importClassName));
109+
return (this.metadata.equals(entry.metadata) && this.importClassName.equals(entry.importClassName));
113110
}
114111

115112
@Override
116113
public int hashCode() {
117-
return Objects.hash(this.metadata, this.importClassName);
114+
return (this.metadata.hashCode() * 31 + this.importClassName.hashCode());
115+
}
116+
117+
@Override
118+
public String toString() {
119+
return this.importClassName;
118120
}
119121
}
120122
}

spring-core/src/main/java/org/springframework/util/unit/DataUnit.java

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,38 +16,53 @@
1616

1717
package org.springframework.util.unit;
1818

19-
import java.util.Objects;
20-
2119
/**
22-
* A standard set of data size units.
20+
* A standard set of {@link DataSize} units.
21+
*
22+
* <p>The unit prefixes used in this class are
23+
* <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a>
24+
* indicating multiplication by powers of 2. The following table displays the
25+
* enum constants defined in this class and corresponding values.
26+
*
27+
* <p>
28+
* <table border="1">
29+
* <tr><th>Constant</th><th>Data Size</th><th>Power&nbsp;of&nbsp;2</th><th>Size in Bytes</th></tr>
30+
* <tr><td>{@link #BYTES}</td><td>1B</td><td>2^0</td><td>1</td></tr>
31+
* <tr><td>{@link #KILOBYTES}</td><td>1KB</td><td>2^10</td><td>1,024</td></tr>
32+
* <tr><td>{@link #MEGABYTES}</td><td>1MB</td><td>2^20</td><td>1,048,576</td></tr>
33+
* <tr><td>{@link #GIGABYTES}</td><td>1GB</td><td>2^30</td><td>1,073,741,824</td></tr>
34+
* <tr><td>{@link #TERABYTES}</td><td>1TB</td><td>2^40</td><td>1,099,511,627,776</td></tr>
35+
* </table>
2336
*
2437
* @author Stephane Nicoll
38+
* @author Sam Brannen
2539
* @since 5.1
40+
* @see DataSize
2641
*/
2742
public enum DataUnit {
2843

2944
/**
30-
* Bytes.
45+
* Bytes, represented by suffix {@code B}.
3146
*/
3247
BYTES("B", DataSize.ofBytes(1)),
3348

3449
/**
35-
* Kilobytes.
50+
* Kilobytes, represented by suffix {@code KB}.
3651
*/
3752
KILOBYTES("KB", DataSize.ofKilobytes(1)),
3853

3954
/**
40-
* Megabytes.
55+
* Megabytes, represented by suffix {@code MB}.
4156
*/
4257
MEGABYTES("MB", DataSize.ofMegabytes(1)),
4358

4459
/**
45-
* Gigabytes.
60+
* Gigabytes, represented by suffix {@code GB}.
4661
*/
4762
GIGABYTES("GB", DataSize.ofGigabytes(1)),
4863

4964
/**
50-
* Terabytes.
65+
* Terabytes, represented by suffix {@code TB}.
5166
*/
5267
TERABYTES("TB", DataSize.ofTerabytes(1));
5368

@@ -68,18 +83,18 @@ DataSize size() {
6883

6984
/**
7085
* Return the {@link DataUnit} matching the specified {@code suffix}.
71-
* @param suffix one of the standard suffix
86+
* @param suffix one of the standard suffixes
7287
* @return the {@link DataUnit} matching the specified {@code suffix}
73-
* @throws IllegalArgumentException if the suffix does not match any
74-
* of this enum's constants
88+
* @throws IllegalArgumentException if the suffix does not match the suffix
89+
* of any of this enum's constants
7590
*/
7691
public static DataUnit fromSuffix(String suffix) {
7792
for (DataUnit candidate : values()) {
78-
if (Objects.equals(candidate.suffix, suffix)) {
93+
if (candidate.suffix.equals(suffix)) {
7994
return candidate;
8095
}
8196
}
82-
throw new IllegalArgumentException("Unknown unit '" + suffix + "'");
97+
throw new IllegalArgumentException("Unknown data unit suffix '" + suffix + "'");
8398
}
8499

85100
}

spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ public Map<String, SimpSession> findSessions(String userName) {
560560
}
561561
return map;
562562
}
563-
564563
}
565564

566565
}

spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
4040
* Mock object based tests for TransactionInterceptor.
4141
*
4242
* @author Rod Johnson
43+
* @author Juergen Hoeller
4344
* @since 16.03.2003
4445
*/
4546
public class TransactionInterceptorTests extends AbstractTransactionAspectTests {
@@ -49,7 +50,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
4950

5051

5152
@Override
52-
protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) throws Exception {
53+
protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) {
5354
TransactionInterceptor ti = new TransactionInterceptor();
5455
ti.setTransactionManager(ptm);
5556
ti.setTransactionAttributeSources(tas);

0 commit comments

Comments
 (0)