Upgrade to spring-javaformat 0.0.6

This commit is contained in:
Stephane Nicoll
2018-07-31 18:01:40 +02:00
parent 76b62a3243
commit fc0b9207f0
26 changed files with 173 additions and 170 deletions

View File

@@ -172,8 +172,8 @@ public class CommandLineHelpGenerator {
.collect(Collectors.toList())) {
String[] data = new String[3];
data[0] = dep.getId();
data[1] = (dep.getDescription() != null ? dep.getDescription()
: dep.getName());
data[1] = (dep.getDescription() != null) ? dep.getDescription()
: dep.getName();
data[2] = dep.getVersionRequirement();
dependencyTable[i++] = data;
}
@@ -195,8 +195,8 @@ public class CommandLineHelpGenerator {
.collect(Collectors.toList())) {
String[] data = new String[typeTable[0].length];
data[0] = (type.isDefault() ? type.getId() + " *" : type.getId());
data[1] = (type.getDescription() != null ? type.getDescription()
: type.getName());
data[1] = (type.getDescription() != null) ? type.getDescription()
: type.getName();
if (addTags) {
data[2] = buildTagRepresentation(type);
}

View File

@@ -451,8 +451,8 @@ public class ProjectGenerator {
model.put("bootTwoZeroAvailable", VERSION_2_0_0_M1.compareTo(bootVersion) <= 0);
// Gradle plugin has changed again as from 1.4.2
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0
? "org.springframework.boot" : "spring-boot"));
model.put("springBootPluginName", (VERSION_1_4_2_M1.compareTo(bootVersion) <= 0)
? "org.springframework.boot" : "spring-boot");
// New testing stuff
model.put("newTestInfrastructure", isNewTestInfrastructureAvailable(request));
@@ -493,9 +493,9 @@ public class ProjectGenerator {
model.put("groupId", bom.getGroupId());
model.put("artifactId", bom.getArtifactId());
model.put("versionToken",
(bom.getVersionProperty() != null ? "${"
(bom.getVersionProperty() != null) ? "${"
+ computeVersionProperty(request, bom.getVersionProperty()) + "}"
: bom.getVersion()));
: bom.getVersion());
return model;
}

View File

@@ -135,8 +135,8 @@ public class ProjectRequest extends BasicProjectRequest {
*/
public void resolve(InitializrMetadata metadata) {
List<String> depIds = (!getStyle().isEmpty() ? getStyle() : getDependencies());
String actualBootVersion = (getBootVersion() != null ? getBootVersion()
: metadata.getBootVersions().getDefault().getId());
String actualBootVersion = (getBootVersion() != null) ? getBootVersion()
: metadata.getBootVersions().getDefault().getId();
Version requestedVersion = Version.parse(actualBootVersion);
this.resolvedDependencies = depIds.stream().map((it) -> {
Dependency dependency = metadata.getDependencies().get(it);
@@ -324,12 +324,12 @@ public class ProjectRequest extends BasicProjectRequest {
@Override
public String toString() {
return "ProjectRequest [" + "parameters=" + this.parameters + ", "
+ (this.resolvedDependencies != null
+ ((this.resolvedDependencies != null)
? "resolvedDependencies=" + this.resolvedDependencies + ", " : "")
+ "boms=" + this.boms + ", " + "repositories=" + this.repositories + ", "
+ "buildProperties=" + this.buildProperties + ", "
+ (this.facets != null ? "facets=" + this.facets + ", " : "")
+ (this.build != null ? "build=" + this.build : "") + "]";
+ ((this.facets != null) ? "facets=" + this.facets + ", " : "")
+ ((this.build != null) ? "build=" + this.build : "") + "]";
}
}

View File

@@ -84,7 +84,7 @@ public class BillOfMaterials {
/**
* Return the version of the BOM. Can be {@code null} if it is provided via a mapping.
* @return The version of the BOM or {@code null}
* @return the version of the BOM or {@code null}
*/
public String getVersion() {
return this.version;
@@ -208,15 +208,16 @@ public class BillOfMaterials {
@Override
public String toString() {
return "BillOfMaterials ["
+ (this.groupId != null ? "groupId=" + this.groupId + ", " : "")
+ (this.artifactId != null ? "artifactId=" + this.artifactId + ", " : "")
+ (this.version != null ? "version=" + this.version + ", " : "")
+ (this.versionProperty != null
+ ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "")
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", "
: "")
+ ((this.version != null) ? "version=" + this.version + ", " : "")
+ ((this.versionProperty != null)
? "versionProperty=" + this.versionProperty + ", " : "")
+ (this.order != null ? "order=" + this.order + ", " : "")
+ (this.additionalBoms != null
+ ((this.order != null) ? "order=" + this.order + ", " : "")
+ ((this.additionalBoms != null)
? "additionalBoms=" + this.additionalBoms + ", " : "")
+ (this.repositories != null ? "repositories=" + this.repositories : "")
+ ((this.repositories != null) ? "repositories=" + this.repositories : "")
+ "]";
}
@@ -310,14 +311,14 @@ public class BillOfMaterials {
@Override
public String toString() {
return "Mapping ["
+ (this.versionRange != null
+ ((this.versionRange != null)
? "versionRange=" + this.versionRange + ", " : "")
+ (this.version != null ? "version=" + this.version + ", " : "")
+ (this.repositories != null
+ ((this.version != null) ? "version=" + this.version + ", " : "")
+ ((this.repositories != null)
? "repositories=" + this.repositories + ", " : "")
+ (this.additionalBoms != null
+ ((this.additionalBoms != null)
? "additionalBoms=" + this.additionalBoms + ", " : "")
+ (this.range != null ? "range=" + this.range : "") + "]";
+ ((this.range != null) ? "range=" + this.range : "") + "]";
}
}

View File

@@ -19,7 +19,7 @@ package io.spring.initializr.metadata;
/**
* Metadata with a default value.
*
* @param <T> The value type
* @param <T> the value type
* @author Dave Syer
*/
public interface Defaultable<T> {

View File

@@ -253,12 +253,12 @@ public class Dependency extends MetadataElement implements Describable {
for (Mapping mapping : this.mappings) {
if (mapping.range.match(bootVersion)) {
Dependency dependency = new Dependency(this);
dependency.groupId = (mapping.groupId != null ? mapping.groupId
: this.groupId);
dependency.artifactId = (mapping.artifactId != null ? mapping.artifactId
: this.artifactId);
dependency.version = (mapping.version != null ? mapping.version
: this.version);
dependency.groupId = (mapping.groupId != null) ? mapping.groupId
: this.groupId;
dependency.artifactId = (mapping.artifactId != null) ? mapping.artifactId
: this.artifactId;
dependency.version = (mapping.version != null) ? mapping.version
: this.version;
dependency.versionRequirement = mapping.range.toString();
dependency.mappings = null;
return dependency;
@@ -327,7 +327,7 @@ public class Dependency extends MetadataElement implements Describable {
/**
* Return the default version, can be {@code null} to indicate that the version is
* managed by the project and does not need to be specified.
* @return The default version or {@code null}
* @return the default version or {@code null}
*/
public String getVersion() {
return this.version;
@@ -465,7 +465,7 @@ public class Dependency extends MetadataElement implements Describable {
dependency.groupId = groupId;
dependency.artifactId = artifactId;
dependency.version = version;
dependency.scope = (scope != null ? scope : SCOPE_COMPILE);
dependency.scope = (scope != null) ? scope : SCOPE_COMPILE;
return dependency;
}

View File

@@ -66,7 +66,7 @@ public class InitializrConfiguration {
* <p>
* No suitable application name can be generated if the name is {@code null} or if it
* contains an invalid character for a class identifier.
* @param name The the source name
* @param name the the source name
* @return the generated application name
* @see Env#getFallbackApplicationName()
* @see Env#getInvalidApplicationNames()
@@ -98,7 +98,7 @@ public class InitializrConfiguration {
* <p>
* The package name cannot be cleaned if the specified {@code packageName} is
* {@code null} or if it contains an invalid character for a class identifier.
* @param packageName The package name
* @param packageName the package name
* @param defaultPackageName the default package name
* @return the cleaned package name
* @see Env#getInvalidPackageNames()
@@ -514,7 +514,7 @@ public class InitializrConfiguration {
/**
* Resolve the parent pom to use. If no custom parent pom is set, the standard
* spring boot parent pom with the specified {@code bootVersion} is used.
* @param bootVersion The Spring Boot version
* @param bootVersion the Spring Boot version
* @return the parent POM
*/
public ParentPom resolveParentPom(String bootVersion) {

View File

@@ -274,7 +274,7 @@ public class InitializrMetadata {
private static String defaultId(
Defaultable<? extends DefaultMetadataElement> element) {
DefaultMetadataElement defaultValue = element.getDefault();
return (defaultValue != null ? defaultValue.getId() : null);
return (defaultValue != null) ? defaultValue.getId() : null;
}
private static class ArtifactIdCapability extends TextCapability {
@@ -289,7 +289,7 @@ public class InitializrMetadata {
@Override
public String getContent() {
String value = super.getContent();
return (value != null ? value : this.nameCapability.getContent());
return (value != null) ? value : this.nameCapability.getContent();
}
}

View File

@@ -98,8 +98,8 @@ public final class InitializrMetadataBuilder {
* @return a new {@link InitializrMetadata} instance
*/
public InitializrMetadata build() {
InitializrConfiguration config = (this.configuration != null ? this.configuration
: new InitializrConfiguration());
InitializrConfiguration config = (this.configuration != null) ? this.configuration
: new InitializrConfiguration();
InitializrMetadata metadata = createInstance(config);
for (InitializrMetadataCustomizer customizer : this.customizers) {
customizer.customize(metadata);

View File

@@ -46,7 +46,7 @@ public class MetadataElement {
}
public String getName() {
return (this.name != null ? this.name : this.id);
return (this.name != null) ? this.name : this.id;
}
public String getId() {

View File

@@ -65,23 +65,6 @@ public class Repository {
this.snapshotsEnabled = snapshotsEnabled;
}
@Override
public String toString() {
return "Repository [" + (this.name != null ? "name=" + this.name + ", " : "")
+ (this.url != null ? "url=" + this.url + ", " : "") + "snapshotsEnabled="
+ this.snapshotsEnabled + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
result = prime * result + (this.snapshotsEnabled ? 1231 : 1237);
result = prime * result + ((this.url == null) ? 0 : this.url.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -116,4 +99,21 @@ public class Repository {
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
result = prime * result + (this.snapshotsEnabled ? 1231 : 1237);
result = prime * result + ((this.url == null) ? 0 : this.url.hashCode());
return result;
}
@Override
public String toString() {
return "Repository [" + ((this.name != null) ? "name=" + this.name + ", " : "")
+ ((this.url != null) ? "url=" + this.url + ", " : "")
+ "snapshotsEnabled=" + this.snapshotsEnabled + "]";
}
}

View File

@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
* Defines a capability of the initializr service. Each capability is defined by a id and
* a {@link ServiceCapabilityType type}.
*
* @param <T> The content type
* @param <T> the content type
* @author Stephane Nicoll
*/
@JsonIgnoreProperties({ "default", "all" })

View File

@@ -82,14 +82,6 @@ public final class Version implements Serializable, Comparable<Version> {
return this.qualifier;
}
@Override
public String toString() {
return this.major + "." + this.minor + "." + this.patch
+ (this.qualifier != null ? "." + this.qualifier.qualifier
+ (this.qualifier.version != null ? this.qualifier.version : "")
: "");
}
/**
* Parse the string representation of a {@link Version}. Throws an
* {@link InvalidVersionException} if the version could not be parsed.
@@ -140,23 +132,11 @@ public final class Version implements Serializable, Comparable<Version> {
}
private static int safeCompare(Integer first, Integer second) {
Integer firstIndex = (first != null ? first : 0);
Integer secondIndex = (second != null ? second : 0);
Integer firstIndex = (first != null) ? first : 0;
Integer secondIndex = (second != null) ? second : 0;
return firstIndex.compareTo(secondIndex);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.major == null) ? 0 : this.major.hashCode());
result = prime * result + ((this.minor == null) ? 0 : this.minor.hashCode());
result = prime * result + ((this.patch == null) ? 0 : this.patch.hashCode());
result = prime * result
+ ((this.qualifier == null) ? 0 : this.qualifier.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -204,6 +184,26 @@ public final class Version implements Serializable, Comparable<Version> {
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.major == null) ? 0 : this.major.hashCode());
result = prime * result + ((this.minor == null) ? 0 : this.minor.hashCode());
result = prime * result + ((this.patch == null) ? 0 : this.patch.hashCode());
result = prime * result
+ ((this.qualifier == null) ? 0 : this.qualifier.hashCode());
return result;
}
@Override
public String toString() {
return this.major + "." + this.minor + "." + this.patch
+ ((this.qualifier != null) ? "." + this.qualifier.qualifier
+ ((this.qualifier.version != null) ? this.qualifier.version : "")
: "");
}
/**
* A version qualifier.
*/
@@ -233,24 +233,6 @@ public final class Version implements Serializable, Comparable<Version> {
this.version = version;
}
@Override
public String toString() {
return "Qualifier ["
+ (this.qualifier != null ? "qualifier=" + this.qualifier + ", " : "")
+ (this.version != null ? "version=" + this.version : "") + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((this.qualifier == null) ? 0 : this.qualifier.hashCode());
result = prime * result
+ ((this.version == null) ? 0 : this.version.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -282,6 +264,25 @@ public final class Version implements Serializable, Comparable<Version> {
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((this.qualifier == null) ? 0 : this.qualifier.hashCode());
result = prime * result
+ ((this.version == null) ? 0 : this.version.hashCode());
return result;
}
@Override
public String toString() {
return "Qualifier ["
+ ((this.qualifier != null) ? "qualifier=" + this.qualifier + ", "
: "")
+ ((this.version != null) ? "version=" + this.version : "") + "]";
}
}
private static class VersionQualifierComparator implements Comparator<Qualifier> {
@@ -296,17 +297,17 @@ public final class Version implements Serializable, Comparable<Version> {
@Override
public int compare(Qualifier o1, Qualifier o2) {
Qualifier first = (o1 != null ? o1 : new Qualifier(RELEASE));
Qualifier second = (o2 != null ? o2 : new Qualifier(RELEASE));
Qualifier first = (o1 != null) ? o1 : new Qualifier(RELEASE);
Qualifier second = (o2 != null) ? o2 : new Qualifier(RELEASE);
int qualifier = compareQualifier(first, second);
return (qualifier != 0 ? qualifier : compareQualifierVersion(first, second));
return (qualifier != 0) ? qualifier : compareQualifierVersion(first, second);
}
private static int compareQualifierVersion(Qualifier first, Qualifier second) {
Integer firstVersion = (first.getVersion() != null ? first.getVersion() : 0);
Integer secondVersion = (second.getVersion() != null ? second.getVersion()
: 0);
Integer firstVersion = (first.getVersion() != null) ? first.getVersion() : 0;
Integer secondVersion = (second.getVersion() != null) ? second.getVersion()
: 0;
return firstVersion.compareTo(secondVersion);
}

View File

@@ -159,7 +159,7 @@ public class VersionParser {
}
return true;
}).collect(Collectors.toList());
return (matches.size() != 1 ? null : matches.get(0));
return (matches.size() != 1) ? null : matches.get(0);
}
}

View File

@@ -82,11 +82,6 @@ public class VersionProperty implements Serializable, Comparable<VersionProperty
return this.property.compareTo(o.property);
}
@Override
public String toString() {
return this.property;
}
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -106,4 +101,9 @@ public class VersionProperty implements Serializable, Comparable<VersionProperty
return this.property.hashCode();
}
@Override
public String toString() {
return this.property;
}
}

View File

@@ -121,32 +121,6 @@ public class VersionRange {
return sb.toString();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.lowerVersion != null) {
sb.append(this.lowerInclusive ? ">=" : ">").append(this.lowerVersion);
}
if (this.higherVersion != null) {
sb.append(" and ").append(this.higherInclusive ? "<=" : "<")
.append(this.higherVersion);
}
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (this.higherInclusive ? 1231 : 1237);
result = prime * result
+ ((this.higherVersion == null) ? 0 : this.higherVersion.hashCode());
result = prime * result + (this.lowerInclusive ? 1231 : 1237);
result = prime * result
+ ((this.lowerVersion == null) ? 0 : this.lowerVersion.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -184,4 +158,30 @@ public class VersionRange {
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (this.higherInclusive ? 1231 : 1237);
result = prime * result
+ ((this.higherVersion == null) ? 0 : this.higherVersion.hashCode());
result = prime * result + (this.lowerInclusive ? 1231 : 1237);
result = prime * result
+ ((this.lowerVersion == null) ? 0 : this.lowerVersion.hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.lowerVersion != null) {
sb.append(this.lowerInclusive ? ">=" : ">").append(this.lowerVersion);
}
if (this.higherVersion != null) {
sb.append(" and ").append(this.higherInclusive ? "<=" : "<")
.append(this.higherVersion);
}
return sb.toString();
}
}