Skip to content

Commit 71cd792

Browse files
committed
Polishing
1 parent 33dc3b0 commit 71cd792

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/SimpleKey.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -32,9 +32,14 @@
3232
@SuppressWarnings("serial")
3333
public class SimpleKey implements Serializable {
3434

35+
/**
36+
* An empty key.
37+
*/
3538
public static final SimpleKey EMPTY = new SimpleKey();
3639

40+
3741
private final Object[] params;
42+
3843
private final int hashCode;
3944

4045

@@ -49,10 +54,11 @@ public SimpleKey(Object... elements) {
4954
this.hashCode = Arrays.deepHashCode(this.params);
5055
}
5156

57+
5258
@Override
53-
public boolean equals(Object obj) {
54-
return (this == obj || (obj instanceof SimpleKey
55-
&& Arrays.deepEquals(this.params, ((SimpleKey) obj).params)));
59+
public boolean equals(Object other) {
60+
return (this == other ||
61+
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
5662
}
5763

5864
@Override

spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected boolean includeOperation(Method method, String beanKey) {
202202
* configured interfaces and is public, otherwise {@code false}.
203203
*/
204204
private boolean isPublicInInterface(Method method, String beanKey) {
205-
return ((method.getModifiers() & Modifier.PUBLIC) > 0) && isDeclaredInInterface(method, beanKey);
205+
return Modifier.isPublic(method.getModifiers()) && isDeclaredInInterface(method, beanKey);
206206
}
207207

208208
/**

spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -44,19 +44,19 @@ public void noValues() {
4444
}
4545

4646
@Test
47-
public void singleValue(){
47+
public void singleValue() {
4848
Object k1 = generateKey(new Object[] { "a" });
4949
Object k2 = generateKey(new Object[] { "a" });
5050
Object k3 = generateKey(new Object[] { "different" });
5151
assertThat(k1.hashCode(), equalTo(k2.hashCode()));
5252
assertThat(k1.hashCode(), not(equalTo(k3.hashCode())));
5353
assertThat(k1, equalTo(k2));
5454
assertThat(k1, not(equalTo(k3)));
55-
assertThat(k1, equalTo((Object) "a"));
55+
assertThat(k1, equalTo("a"));
5656
}
5757

5858
@Test
59-
public void multipleValues() {
59+
public void multipleValues() {
6060
Object k1 = generateKey(new Object[] { "a", 1, "b" });
6161
Object k2 = generateKey(new Object[] { "a", 1, "b" });
6262
Object k3 = generateKey(new Object[] { "b", 1, "a" });

0 commit comments

Comments
 (0)