Unify method visibility of private classes

Apply checkstyle rule to ensure that private and package private
classes do not have unnecessary public methods. Test classes have
also been unified as much as possible to use default scoped
inner-classes.

Closes gh-7316
This commit is contained in:
Phillip Webb
2019-07-01 12:29:51 -07:00
parent 0a02a3a19c
commit a66c4d3096
910 changed files with 3754 additions and 3945 deletions

View File

@@ -1034,14 +1034,14 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
this.jsonPath = JsonPath.compile(this.expression);
}
public void assertHasEmptyValue() {
void assertHasEmptyValue() {
if (ObjectUtils.isEmpty(getValue(false)) || isIndefiniteAndEmpty()) {
return;
}
failWithMessage(getExpectedValueMessage("an empty value"));
}
public void assertDoesNotHaveEmptyValue() {
void assertDoesNotHaveEmptyValue() {
if (!ObjectUtils.isEmpty(getValue(false))) {
return;
}
@@ -1049,7 +1049,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
public void assertHasValue(Class<?> type, String expectedDescription) {
void assertHasValue(Class<?> type, String expectedDescription) {
Object value = getValue(true);
if (value == null || isIndefiniteAndEmpty()) {
failWithMessage(getNoValueMessage());
@@ -1059,7 +1059,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
}
public void assertDoesNotHaveValue() {
void assertDoesNotHaveValue() {
if (getValue(false) == null || isIndefiniteAndEmpty()) {
return;
}
@@ -1078,7 +1078,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
return ObjectUtils.isEmpty(getValue(false));
}
public Object getValue(boolean required) {
Object getValue(boolean required) {
try {
CharSequence json = JsonContentAssert.this.actual;
return this.jsonPath.read((json != null) ? json.toString() : null,

View File

@@ -47,7 +47,7 @@ abstract class Definition {
* Return the name for bean.
* @return the name or {@code null}
*/
public String getName() {
String getName() {
return this.name;
}
@@ -55,7 +55,7 @@ abstract class Definition {
* Return the mock reset mode.
* @return the reset mode
*/
public MockReset getReset() {
MockReset getReset() {
return this.reset;
}
@@ -63,7 +63,7 @@ abstract class Definition {
* Return if AOP advised beans should be proxy target aware.
* @return if proxy target aware
*/
public boolean isProxyTargetAware() {
boolean isProxyTargetAware() {
return this.proxyTargetAware;
}
@@ -71,7 +71,7 @@ abstract class Definition {
* Return the qualifier or {@code null}.
* @return the qualifier
*/
public QualifierDefinition getQualifier() {
QualifierDefinition getQualifier() {
return this.qualifier;
}

View File

@@ -59,7 +59,7 @@ class DefinitionsParser {
}
}
public void parse(Class<?> source) {
void parse(Class<?> source) {
parseElement(source);
ReflectionUtils.doWithFields(source, this::parseElement);
}
@@ -119,11 +119,11 @@ class DefinitionsParser {
return types;
}
public Set<Definition> getDefinitions() {
Set<Definition> getDefinitions() {
return Collections.unmodifiableSet(this.definitions);
}
public Field getField(Definition definition) {
Field getField(Definition definition) {
return this.definitionFields.get(definition);
}

View File

@@ -71,7 +71,7 @@ class MockDefinition extends Definition {
* Return the type that should be mocked.
* @return the type to mock; never {@code null}
*/
public ResolvableType getTypeToMock() {
ResolvableType getTypeToMock() {
return this.typeToMock;
}
@@ -79,7 +79,7 @@ class MockDefinition extends Definition {
* Return the extra interfaces.
* @return the extra interfaces or an empty set
*/
public Set<Class<?>> getExtraInterfaces() {
Set<Class<?>> getExtraInterfaces() {
return this.extraInterfaces;
}
@@ -87,7 +87,7 @@ class MockDefinition extends Definition {
* Return the answers mode.
* @return the answers mode; never {@code null}
*/
public Answers getAnswer() {
Answers getAnswer() {
return this.answer;
}
@@ -95,7 +95,7 @@ class MockDefinition extends Definition {
* Return if the mock is serializable.
* @return if the mock is serializable
*/
public boolean isSerializable() {
boolean isSerializable() {
return this.serializable;
}
@@ -133,12 +133,12 @@ class MockDefinition extends Definition {
.append("serializable", this.serializable).append("reset", getReset()).toString();
}
public <T> T createMock() {
<T> T createMock() {
return createMock(getName());
}
@SuppressWarnings("unchecked")
public <T> T createMock(String name) {
<T> T createMock(String name) {
MockSettings settings = MockReset.withSettings(getReset());
if (StringUtils.hasLength(name)) {
settings.name(name);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-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.
@@ -126,7 +126,7 @@ public enum MockReset {
this.reset = reset;
}
public MockReset getReset() {
MockReset getReset() {
return this.reset;
}

View File

@@ -455,7 +455,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
return this.mockitoPostProcessor.createSpyIfNecessary(bean, beanName);
}
public static void register(BeanDefinitionRegistry registry) {
static void register(BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(BEAN_NAME)) {
RootBeanDefinition definition = new RootBeanDefinition(SpyPostProcessor.class);
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

View File

@@ -119,7 +119,7 @@ public class MockitoTestExecutionListener extends AbstractTestExecutionListener
}
}
public boolean hasAnnotations() {
boolean hasAnnotations() {
return !this.annotations.isEmpty();
}

View File

@@ -52,11 +52,11 @@ class QualifierDefinition {
this.annotations = annotations;
}
public boolean matches(ConfigurableListableBeanFactory beanFactory, String beanName) {
boolean matches(ConfigurableListableBeanFactory beanFactory, String beanName) {
return beanFactory.isAutowireCandidate(beanName, this.descriptor);
}
public void applyTo(RootBeanDefinition definition) {
void applyTo(RootBeanDefinition definition) {
definition.setQualifiedElement(this.field);
}
@@ -77,7 +77,7 @@ class QualifierDefinition {
return this.annotations.hashCode();
}
public static QualifierDefinition forElement(AnnotatedElement element) {
static QualifierDefinition forElement(AnnotatedElement element) {
if (element != null && element instanceof Field) {
Field field = (Field) element;
Set<Annotation> annotations = getQualifierAnnotations(field);

View File

@@ -47,7 +47,7 @@ class SpyDefinition extends Definition {
}
public ResolvableType getTypeToSpy() {
ResolvableType getTypeToSpy() {
return this.typeToSpy;
}
@@ -78,12 +78,12 @@ class SpyDefinition extends Definition {
.append("reset", getReset()).toString();
}
public <T> T createSpy(Object instance) {
<T> T createSpy(Object instance) {
return createSpy(getName(), instance);
}
@SuppressWarnings("unchecked")
public <T> T createSpy(String name, Object instance) {
<T> T createSpy(String name, Object instance) {
Assert.notNull(instance, "Instance must not be null");
Assert.isInstanceOf(this.typeToSpy.resolve(), instance);
if (Mockito.mockingDetails(instance).isSpy()) {

View File

@@ -154,7 +154,7 @@ class OutputCapture implements CapturedOutput {
System.setErr(this.err);
}
public void release() {
void release() {
System.setOut(this.out.getParent());
System.setErr(this.err.getParent());
}
@@ -171,7 +171,7 @@ class OutputCapture implements CapturedOutput {
}
}
public void append(StringBuilder builder, Predicate<Type> filter) {
void append(StringBuilder builder, Predicate<Type> filter) {
synchronized (this.monitor) {
for (CapturedString stringCapture : this.capturedStrings) {
if (filter.test(stringCapture.getType())) {
@@ -181,7 +181,7 @@ class OutputCapture implements CapturedOutput {
}
}
public void reset() {
void reset() {
synchronized (this.monitor) {
this.capturedStrings.clear();
}
@@ -201,7 +201,7 @@ class OutputCapture implements CapturedOutput {
this.parent = parent;
}
public PrintStream getParent() {
PrintStream getParent() {
return this.parent;
}
@@ -260,7 +260,7 @@ class OutputCapture implements CapturedOutput {
this.string = string;
}
public Type getType() {
Type getType() {
return this.type;
}
@@ -292,11 +292,11 @@ class OutputCapture implements CapturedOutput {
AnsiOutput.setEnabled(Enabled.NEVER);
}
public void restore() {
void restore() {
AnsiOutput.setEnabled(this.saved);
}
public static AnsiOutputState saveAndDisable() {
static AnsiOutputState saveAndDisable() {
if (!ClassUtils.isPresent("org.springframework.boot.ansi.AnsiOutput",
OutputCapture.class.getClassLoader())) {
return null;