Upgrade to spring-javaformat 0.0.6

This commit is contained in:
Phillip Webb
2018-08-28 15:22:36 -07:00
parent 17de1571f5
commit 9543fcf44d
290 changed files with 1021 additions and 1014 deletions

View File

@@ -116,11 +116,6 @@ class ImportsContextCustomizer implements ContextCustomizer {
return definition;
}
@Override
public int hashCode() {
return this.key.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -134,6 +129,11 @@ class ImportsContextCustomizer implements ContextCustomizer {
return this.key.equals(other.key);
}
@Override
public int hashCode() {
return this.key.hashCode();
}
@Override
public String toString() {
return new ToStringCreator(this).append("key", this.key).toString();
@@ -169,10 +169,10 @@ class ImportsContextCustomizer implements ContextCustomizer {
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
BeanDefinition definition = this.beanFactory
.getBeanDefinition(ImportsConfiguration.BEAN_NAME);
Object testClass = (definition != null
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null);
return (testClass != null ? new String[] { ((Class<?>) testClass).getName() }
: NO_IMPORTS);
Object testClass = (definition != null)
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null;
return (testClass != null) ? new String[] { ((Class<?>) testClass).getName() }
: NO_IMPORTS;
}
}
@@ -246,7 +246,7 @@ class ImportsContextCustomizer implements ContextCustomizer {
collectClassAnnotations(testClass, annotations, seen);
Set<Object> determinedImports = determineImports(annotations, testClass);
this.key = Collections.<Object>unmodifiableSet(
determinedImports != null ? determinedImports : annotations);
(determinedImports != null) ? determinedImports : annotations);
}
private void collectClassAnnotations(Class<?> classType,
@@ -339,17 +339,17 @@ class ImportsContextCustomizer implements ContextCustomizer {
}
}
@Override
public int hashCode() {
return this.key.hashCode();
}
@Override
public boolean equals(Object obj) {
return (obj != null && getClass().equals(obj.getClass())
&& this.key.equals(((ContextCustomizerKey) obj).key));
}
@Override
public int hashCode() {
return this.key.hashCode();
}
@Override
public String toString() {
return this.key.toString();

View File

@@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder {
private String getParentPackage(String sourcePackage) {
int lastDot = sourcePackage.lastIndexOf(".");
return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : "");
return (lastDot != -1) ? sourcePackage.substring(0, lastDot) : "";
}
/**

View File

@@ -98,9 +98,9 @@ public class SpringBootContextLoader extends AbstractContextLoader {
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
setActiveProfiles(environment, config.getActiveProfiles());
}
ResourceLoader resourceLoader = (application.getResourceLoader() != null
ResourceLoader resourceLoader = (application.getResourceLoader() != null)
? application.getResourceLoader()
: new DefaultResourceLoader(getClass().getClassLoader()));
: new DefaultResourceLoader(getClass().getClassLoader());
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment,
resourceLoader, config.getPropertySourceLocations());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,

View File

@@ -147,8 +147,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
WebAppConfiguration webAppConfiguration = AnnotatedElementUtils
.findMergedAnnotation(mergedConfig.getTestClass(),
WebAppConfiguration.class);
String resourceBasePath = (webAppConfiguration != null
? webAppConfiguration.value() : "src/main/webapp");
String resourceBasePath = (webAppConfiguration != null)
? webAppConfiguration.value() : "src/main/webapp";
mergedConfig = new WebMergedContextConfiguration(mergedConfig,
resourceBasePath);
}
@@ -275,17 +275,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
*/
protected WebEnvironment getWebEnvironment(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation != null ? annotation.webEnvironment() : null);
return (annotation != null) ? annotation.webEnvironment() : null;
}
protected Class<?>[] getClasses(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation != null ? annotation.classes() : null);
return (annotation != null) ? annotation.classes() : null;
}
protected String[] getProperties(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation != null ? annotation.properties() : null);
return (annotation != null) ? annotation.properties() : null;
}
protected SpringBootTest getAnnotation(Class<?> testClass) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -66,11 +66,6 @@ class SpringBootTestContextCustomizer implements ContextCustomizer {
new RootBeanDefinition(TestRestTemplateFactory.class));
}
@Override
public int hashCode() {
return getClass().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
@@ -79,6 +74,11 @@ class SpringBootTestContextCustomizer implements ContextCustomizer {
return true;
}
@Override
public int hashCode() {
return getClass().hashCode();
}
/**
* {@link FactoryBean} used to create and configure a {@link TestRestTemplate}.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -36,11 +36,6 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer {
new TestTypeExcludeFilter());
}
@Override
public int hashCode() {
return getClass().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -52,4 +47,9 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer {
return true;
}
@Override
public int hashCode() {
return getClass().hashCode();
}
}

View File

@@ -354,7 +354,7 @@ public abstract class AbstractJsonMarshalTester<T> {
* Utility class used to support field initialization. Used by subclasses to support
* {@code initFields}.
*
* @param <M> The marshaller type
* @param <M> the marshaller type
*/
protected abstract static class FieldInitializer<M> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -105,7 +105,7 @@ public class BasicJsonTester {
* Create JSON content from the specified String source. The source can contain the
* JSON itself or, if it ends with {@code .json}, the name of a resource to be loaded
* using {@code resourceLoadClass}.
* @param source JSON content or a {@code .json} resource name
* @param source the JSON content or a {@code .json} resource name
* @return the JSON content
*/
public JsonContent<Object> from(CharSequence source) {

View File

@@ -86,11 +86,6 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa
this.logger.warn(message);
}
@Override
public int hashCode() {
return getClass().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
@@ -99,6 +94,11 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa
return true;
}
@Override
public int hashCode() {
return getClass().hashCode();
}
}
}

View File

@@ -75,7 +75,7 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
@Override
public String toString() {
return "JsonContent " + this.json
+ (this.type != null ? " created from " + this.type : "");
+ ((this.type != null) ? " created from " + this.type : "");
}
}

View File

@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson != null ? expectedJson.toString() : null),
(expectedJson != null) ? expectedJson.toString() : null,
this.actual.toString(), compareMode);
}
catch (Exception ex) {
@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson != null ? expectedJson.toString() : null),
(expectedJson != null) ? expectedJson.toString() : null,
this.actual.toString(), comparator);
}
catch (Exception ex) {
@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JsonPathValue(CharSequence expression, Object... args) {
org.springframework.util.Assert.hasText(
(expression != null ? expression.toString() : null),
(expression != null) ? expression.toString() : null,
"expression must not be null or empty");
this.expression = String.format(expression.toString(), args);
this.jsonPath = JsonPath.compile(this.expression);
@@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
public Object getValue(boolean required) {
try {
CharSequence json = JsonContentAssert.this.actual;
return this.jsonPath.read(json != null ? json.toString() : null);
return this.jsonPath.read((json != null) ? json.toString() : null);
}
catch (Exception ex) {
if (!required) {

View File

@@ -42,7 +42,7 @@ class JsonLoader {
JsonLoader(Class<?> resourceLoadClass, Charset charset) {
this.resourceLoadClass = resourceLoadClass;
this.charset = (charset != null ? charset : Charset.forName("UTF-8"));
this.charset = (charset != null) ? charset : Charset.forName("UTF-8");
}
Class<?> getResourceLoadClass() {

View File

@@ -63,7 +63,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
@Override
public String toString() {
return "ObjectContent " + this.object
+ (this.type != null ? " created from " + this.type : "");
+ ((this.type != null) ? " created from " + this.type : "");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -28,7 +28,7 @@ import org.assertj.core.internal.Objects;
/**
* AssertJ {@link Assert} for {@link ObjectContent}.
*
* @param <A> The actual type
* @param <A> the actual type
* @author Phillip Webb
* @since 1.4.0
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-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.
@@ -39,7 +39,7 @@ abstract class Definition {
Definition(String name, MockReset reset, boolean proxyTargetAware,
QualifierDefinition qualifier) {
this.name = name;
this.reset = (reset != null ? reset : MockReset.AFTER);
this.reset = (reset != null) ? reset : MockReset.AFTER;
this.proxyTargetAware = proxyTargetAware;
this.qualifier = qualifier;
}
@@ -76,17 +76,6 @@ abstract class Definition {
return this.qualifier;
}
@Override
public int hashCode() {
int result = 1;
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset);
result = MULTIPLIER * result
+ ObjectUtils.nullSafeHashCode(this.proxyTargetAware);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier);
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -105,4 +94,15 @@ abstract class Definition {
return result;
}
@Override
public int hashCode() {
int result = 1;
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset);
result = MULTIPLIER * result
+ ObjectUtils.nullSafeHashCode(this.proxyTargetAware);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier);
return result;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-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.
@@ -56,7 +56,7 @@ class MockDefinition extends Definition {
Assert.notNull(typeToMock, "TypeToMock must not be null");
this.typeToMock = typeToMock;
this.extraInterfaces = asClassSet(extraInterfaces);
this.answer = (answer != null ? answer : Answers.RETURNS_DEFAULTS);
this.answer = (answer != null) ? answer : Answers.RETURNS_DEFAULTS;
this.serializable = serializable;
}
@@ -100,16 +100,6 @@ class MockDefinition extends Definition {
return this.serializable;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer);
result = MULTIPLIER * result + (this.serializable ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -128,6 +118,16 @@ class MockDefinition extends Definition {
return result;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces);
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer);
result = MULTIPLIER * result + (this.serializable ? 1231 : 1237);
return result;
}
@Override
public String toString() {
return new ToStringCreator(this).append("name", getName())

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -46,11 +46,6 @@ class MockitoContextCustomizer implements ContextCustomizer {
}
}
@Override
public int hashCode() {
return this.definitions.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -63,4 +58,9 @@ class MockitoContextCustomizer implements ContextCustomizer {
return this.definitions.equals(other.definitions);
}
@Override
public int hashCode() {
return this.definitions.hashCode();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-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.
@@ -60,11 +60,6 @@ class QualifierDefinition {
definition.setQualifiedElement(this.field);
}
@Override
public int hashCode() {
return this.annotations.hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -77,6 +72,11 @@ class QualifierDefinition {
return this.annotations.equals(other.annotations);
}
@Override
public int hashCode() {
return this.annotations.hashCode();
}
public static QualifierDefinition forElement(AnnotatedElement element) {
if (element != null && element instanceof Field) {
Field field = (Field) element;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-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.
@@ -48,13 +48,6 @@ class SpyDefinition extends Definition {
return this.typeToSpy;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy);
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
@@ -69,6 +62,13 @@ class SpyDefinition extends Definition {
return result;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy);
return result;
}
@Override
public String toString() {
return new ToStringCreator(this).append("name", getName())

View File

@@ -71,8 +71,8 @@ public abstract class EnvironmentTestUtils {
Map<String, Object> map = getOrAdd(sources, name);
for (String pair : pairs) {
int index = getSeparatorIndex(pair);
String key = pair.substring(0, index > 0 ? index : pair.length());
String value = (index > 0 ? pair.substring(index + 1) : "");
String key = pair.substring(0, (index > 0) ? index : pair.length());
String value = (index > 0) ? pair.substring(index + 1) : "";
map.put(key.trim(), value.trim());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-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.
@@ -43,11 +43,6 @@ public class ExampleObject {
this.age = age;
}
@Override
public int hashCode() {
return 0;
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
@@ -58,6 +53,11 @@ public class ExampleObject {
&& ObjectUtils.nullSafeEquals(this.age, other.age);
}
@Override
public int hashCode() {
return 0;
}
@Override
public String toString() {
return this.name + " " + this.age;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-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.
@@ -48,11 +48,6 @@ public class ExampleObjectWithView {
this.age = age;
}
@Override
public int hashCode() {
return 0;
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) {
@@ -63,6 +58,11 @@ public class ExampleObjectWithView {
&& ObjectUtils.nullSafeEquals(this.age, other.age);
}
@Override
public int hashCode() {
return 0;
}
@Override
public String toString() {
return this.name + " " + this.age;