Upgrade to spring-javaformat 0.0.6
This commit is contained in:
@@ -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.
|
||||
@@ -150,7 +150,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
|
||||
private String toCommaDelimitedString(List<Object> list) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (Object item : list) {
|
||||
result.append(result.length() != 0 ? "," : "");
|
||||
result.append((result.length() != 0) ? "," : "");
|
||||
result.append(item);
|
||||
}
|
||||
return result.toString();
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractConfigurationMetadataTests {
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.getId()).isEqualTo(id);
|
||||
assertThat(actual.getName()).isEqualTo(name);
|
||||
String typeName = (type != null ? type.getName() : null);
|
||||
String typeName = (type != null) ? type.getName() : null;
|
||||
assertThat(actual.getType()).isEqualTo(typeName);
|
||||
assertThat(actual.getDefaultValue()).isEqualTo(defaultValue);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix,
|
||||
this.typeUtils.getQualifiedName(returnElement),
|
||||
this.typeUtils.getQualifiedName(element),
|
||||
(getter != null ? getter.toString() : null)));
|
||||
(getter != null) ? getter.toString() : null));
|
||||
processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -51,8 +51,8 @@ public class MetadataCollector {
|
||||
|
||||
/**
|
||||
* Creates a new {@code MetadataProcessor} instance.
|
||||
* @param processingEnvironment The processing environment of the build
|
||||
* @param previousMetadata Any previous metadata or {@code null}
|
||||
* @param processingEnvironment the processing environment of the build
|
||||
* @param previousMetadata any previous metadata or {@code null}
|
||||
*/
|
||||
public MetadataCollector(ProcessingEnvironment processingEnvironment,
|
||||
ConfigurationMetadata previousMetadata) {
|
||||
|
||||
@@ -139,8 +139,8 @@ class TypeUtils {
|
||||
}
|
||||
|
||||
public String getJavaDoc(Element element) {
|
||||
String javadoc = (element != null
|
||||
? this.env.getElementUtils().getDocComment(element) : null);
|
||||
String javadoc = (element != null)
|
||||
? this.env.getElementUtils().getDocComment(element) : null;
|
||||
if (javadoc != null) {
|
||||
javadoc = javadoc.replaceAll("[\r\n]+", "").trim();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ final class Trees extends ReflectionWrapper {
|
||||
|
||||
public Tree getTree(Element element) throws Exception {
|
||||
Object tree = findMethod("getTree", Element.class).invoke(getInstance(), element);
|
||||
return (tree != null ? new Tree(tree) : null);
|
||||
return (tree != null) ? new Tree(tree) : null;
|
||||
}
|
||||
|
||||
public static Trees instance(ProcessingEnvironment env) throws Exception {
|
||||
|
||||
@@ -43,7 +43,7 @@ class VariableTree extends ReflectionWrapper {
|
||||
|
||||
public ExpressionTree getInitializer() throws Exception {
|
||||
Object instance = findMethod("getInitializer").invoke(getInstance());
|
||||
return (instance != null ? new ExpressionTree(instance) : null);
|
||||
return (instance != null) ? new ExpressionTree(instance) : null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -169,8 +169,8 @@ public class ConfigurationMetadata {
|
||||
|
||||
private List<ItemMetadata> getCandidates(String name) {
|
||||
List<ItemMetadata> candidates = this.items.get(name);
|
||||
return (candidates != null ? new ArrayList<ItemMetadata>(candidates)
|
||||
: new ArrayList<ItemMetadata>());
|
||||
return (candidates != null) ? new ArrayList<ItemMetadata>(candidates)
|
||||
: new ArrayList<ItemMetadata>();
|
||||
}
|
||||
|
||||
private boolean nullSafeEquals(Object o1, Object o2) {
|
||||
@@ -181,7 +181,7 @@ public class ConfigurationMetadata {
|
||||
}
|
||||
|
||||
public static String nestedPrefix(String prefix, String name) {
|
||||
String nestedPrefix = (prefix != null ? prefix : "");
|
||||
String nestedPrefix = (prefix != null) ? prefix : "";
|
||||
String dashedName = toDashedCase(name);
|
||||
nestedPrefix += ("".equals(nestedPrefix) ? dashedName : "." + dashedName);
|
||||
return nestedPrefix;
|
||||
|
||||
@@ -68,13 +68,6 @@ public class ItemDeprecation {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
|
||||
+ "replacement='" + this.replacement + '\'' + ", " + "level='"
|
||||
+ this.level + '\'' + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@@ -97,6 +90,13 @@ public class ItemDeprecation {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", "
|
||||
+ "replacement='" + this.replacement + '\'' + ", " + "level='"
|
||||
+ this.level + '\'' + '}';
|
||||
}
|
||||
|
||||
private boolean nullSafeEquals(Object o1, Object o2) {
|
||||
if (o1 == o2) {
|
||||
return true;
|
||||
@@ -108,7 +108,7 @@ public class ItemDeprecation {
|
||||
}
|
||||
|
||||
private int nullSafeHashCode(Object o) {
|
||||
return (o != null ? o.hashCode() : 0);
|
||||
return (o != null) ? o.hashCode() : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -44,10 +44,10 @@ public class ItemHint implements Comparable<ItemHint> {
|
||||
|
||||
public ItemHint(String name, List<ValueHint> values, List<ValueProvider> providers) {
|
||||
this.name = toCanonicalName(name);
|
||||
this.values = (values != null ? new ArrayList<ValueHint>(values)
|
||||
: new ArrayList<ValueHint>());
|
||||
this.providers = (providers != null ? new ArrayList<ValueProvider>(providers)
|
||||
: new ArrayList<ValueProvider>());
|
||||
this.values = (values != null) ? new ArrayList<ValueHint>(values)
|
||||
: new ArrayList<ValueHint>();
|
||||
this.providers = (providers != null) ? new ArrayList<ValueProvider>(providers)
|
||||
: new ArrayList<ValueProvider>();
|
||||
}
|
||||
|
||||
private String toCanonicalName(String name) {
|
||||
|
||||
@@ -60,11 +60,11 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
|
||||
while (prefix != null && prefix.endsWith(".")) {
|
||||
prefix = prefix.substring(0, prefix.length() - 1);
|
||||
}
|
||||
StringBuilder fullName = new StringBuilder(prefix != null ? prefix : "");
|
||||
StringBuilder fullName = new StringBuilder((prefix != null) ? prefix : "");
|
||||
if (fullName.length() > 0 && name != null) {
|
||||
fullName.append(".");
|
||||
}
|
||||
fullName.append(name != null ? ConfigurationMetadata.toDashedCase(name) : "");
|
||||
fullName.append((name != null) ? ConfigurationMetadata.toDashedCase(name) : "");
|
||||
return fullName.toString();
|
||||
}
|
||||
|
||||
@@ -132,17 +132,6 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
|
||||
this.deprecation = deprecation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder string = new StringBuilder(this.name);
|
||||
buildToStringProperty(string, "type", this.type);
|
||||
buildToStringProperty(string, "sourceType", this.sourceType);
|
||||
buildToStringProperty(string, "description", this.description);
|
||||
buildToStringProperty(string, "defaultValue", this.defaultValue);
|
||||
buildToStringProperty(string, "deprecation", this.deprecation);
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
protected void buildToStringProperty(StringBuilder string, String property,
|
||||
Object value) {
|
||||
if (value != null) {
|
||||
@@ -182,6 +171,17 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder string = new StringBuilder(this.name);
|
||||
buildToStringProperty(string, "type", this.type);
|
||||
buildToStringProperty(string, "sourceType", this.sourceType);
|
||||
buildToStringProperty(string, "description", this.description);
|
||||
buildToStringProperty(string, "defaultValue", this.defaultValue);
|
||||
buildToStringProperty(string, "deprecation", this.deprecation);
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
private boolean nullSafeEquals(Object o1, Object o2) {
|
||||
if (o1 == o2) {
|
||||
return true;
|
||||
@@ -193,7 +193,7 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
|
||||
}
|
||||
|
||||
private int nullSafeHashCode(Object o) {
|
||||
return (o != null ? o.hashCode() : 0);
|
||||
return (o != null) ? o.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SpringBootPluginExtension {
|
||||
* @return the Layout to use or null if not explicitly set
|
||||
*/
|
||||
public Layout convertLayout() {
|
||||
return (this.layout != null ? this.layout.layout : null);
|
||||
return (this.layout != null) ? this.layout.layout : null;
|
||||
}
|
||||
|
||||
public String getMainClass() {
|
||||
|
||||
@@ -114,8 +114,8 @@ class ProjectLibraries implements Libraries {
|
||||
|
||||
private Set<GradleLibrary> getLibraries(String configurationName,
|
||||
LibraryScope scope) {
|
||||
Configuration configuration = (configurationName != null
|
||||
? this.project.getConfigurations().findByName(configurationName) : null);
|
||||
Configuration configuration = (configurationName != null)
|
||||
? this.project.getConfigurations().findByName(configurationName) : null;
|
||||
if (configuration == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -233,11 +233,6 @@ class ProjectLibraries implements Libraries {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getFile().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof GradleLibrary) {
|
||||
@@ -246,6 +241,11 @@ class ProjectLibraries implements Libraries {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getFile().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFile().getAbsolutePath();
|
||||
@@ -321,7 +321,7 @@ class ProjectLibraries implements Libraries {
|
||||
String configurationName = (String) this.getTargetConfiguration
|
||||
.invoke(projectDependency);
|
||||
return projectDependency.getDependencyProject().getConfigurations()
|
||||
.getByName(configurationName != null ? configurationName
|
||||
.getByName((configurationName != null) ? configurationName
|
||||
: Dependency.DEFAULT_CONFIGURATION);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
@@ -145,7 +145,7 @@ public class RepackageTask extends DefaultTask {
|
||||
SpringBootPluginExtension extension = project.getExtensions()
|
||||
.getByType(SpringBootPluginExtension.class);
|
||||
ProjectLibraries libraries = new ProjectLibraries(project, extension,
|
||||
this.excludeDevtools != null ? this.excludeDevtools
|
||||
(this.excludeDevtools != null) ? this.excludeDevtools
|
||||
: extension.isExcludeDevtools());
|
||||
if (extension.getProvidedConfiguration() != null) {
|
||||
libraries.setProvidedConfigurationName(extension.getProvidedConfiguration());
|
||||
@@ -293,20 +293,20 @@ public class RepackageTask extends DefaultTask {
|
||||
}
|
||||
|
||||
private boolean isExecutable() {
|
||||
return (RepackageTask.this.executable != null ? RepackageTask.this.executable
|
||||
: this.extension.isExecutable());
|
||||
return (RepackageTask.this.executable != null) ? RepackageTask.this.executable
|
||||
: this.extension.isExecutable();
|
||||
}
|
||||
|
||||
private File getEmbeddedLaunchScript() {
|
||||
return (RepackageTask.this.embeddedLaunchScript != null
|
||||
return (RepackageTask.this.embeddedLaunchScript != null)
|
||||
? RepackageTask.this.embeddedLaunchScript
|
||||
: this.extension.getEmbeddedLaunchScript());
|
||||
: this.extension.getEmbeddedLaunchScript();
|
||||
}
|
||||
|
||||
private Map<String, String> getEmbeddedLaunchScriptProperties() {
|
||||
return (RepackageTask.this.embeddedLaunchScriptProperties != null
|
||||
return (RepackageTask.this.embeddedLaunchScriptProperties != null)
|
||||
? RepackageTask.this.embeddedLaunchScriptProperties
|
||||
: this.extension.getEmbeddedLaunchScriptProperties());
|
||||
: this.extension.getEmbeddedLaunchScriptProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class BootRunTask extends JavaExec {
|
||||
private void addResourcesIfNecessary() {
|
||||
if (this.addResources) {
|
||||
SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
|
||||
final File outputDir = (mainSourceSet != null
|
||||
? mainSourceSet.getOutput().getResourcesDir() : null);
|
||||
final File outputDir = (mainSourceSet != null)
|
||||
? mainSourceSet.getOutput().getResourcesDir() : null;
|
||||
final Set<File> resources = new LinkedHashSet<File>();
|
||||
if (mainSourceSet != null) {
|
||||
resources.addAll(mainSourceSet.getResources().getSrcDirs());
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DefaultLaunchScript implements LaunchScript {
|
||||
value = (String) properties.get(name);
|
||||
}
|
||||
else {
|
||||
value = (value != null ? value.substring(1) : matcher.group(0));
|
||||
value = (value != null) ? value.substring(1) : matcher.group(0);
|
||||
}
|
||||
matcher.appendReplacement(expanded, value.replace("$", "\\$"));
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ public class JarWriter implements LoaderClassesWriter {
|
||||
|
||||
/**
|
||||
* Writes an entry. The {@code inputStream} is closed once the entry has been written
|
||||
* @param entryName The name of the entry
|
||||
* @param inputStream The stream from which the entry's data can be read
|
||||
* @param entryName the name of the entry
|
||||
* @param inputStream the stream from which the entry's data can be read
|
||||
* @throws IOException if the write fails
|
||||
*/
|
||||
@Override
|
||||
@@ -340,7 +340,7 @@ public class JarWriter implements LoaderClassesWriter {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int read = (this.headerStream != null ? this.headerStream.read() : -1);
|
||||
int read = (this.headerStream != null) ? this.headerStream.read() : -1;
|
||||
if (read != -1) {
|
||||
this.position++;
|
||||
if (this.position >= this.headerLength) {
|
||||
@@ -358,8 +358,8 @@ public class JarWriter implements LoaderClassesWriter {
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int read = (this.headerStream != null ? this.headerStream.read(b, off, len)
|
||||
: -1);
|
||||
int read = (this.headerStream != null) ? this.headerStream.read(b, off, len)
|
||||
: -1;
|
||||
if (read <= 0) {
|
||||
return readRemainder(b, off, len);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Library {
|
||||
* @param unpackRequired if the library needs to be unpacked before it can be used
|
||||
*/
|
||||
public Library(String name, File file, LibraryScope scope, boolean unpackRequired) {
|
||||
this.name = (name != null ? name : file.getName());
|
||||
this.name = (name != null) ? name : file.getName();
|
||||
this.file = file;
|
||||
this.scope = scope;
|
||||
this.unpackRequired = unpackRequired;
|
||||
|
||||
@@ -312,7 +312,7 @@ public abstract class MainClassFinder {
|
||||
|
||||
private static List<JarEntry> getClassEntries(JarFile source,
|
||||
String classesLocation) {
|
||||
classesLocation = (classesLocation != null ? classesLocation : "");
|
||||
classesLocation = (classesLocation != null) ? classesLocation : "";
|
||||
Enumeration<JarEntry> sourceEntries = source.entries();
|
||||
List<JarEntry> classEntries = new ArrayList<JarEntry>();
|
||||
while (sourceEntries.hasMoreElements()) {
|
||||
@@ -448,16 +448,6 @@ public abstract class MainClassFinder {
|
||||
return this.annotationNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
@@ -476,6 +466,16 @@ public abstract class MainClassFinder {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,8 +116,8 @@ public abstract class Launcher {
|
||||
protected final Archive createArchive() throws Exception {
|
||||
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
|
||||
CodeSource codeSource = protectionDomain.getCodeSource();
|
||||
URI location = (codeSource != null ? codeSource.getLocation().toURI() : null);
|
||||
String path = (location != null ? location.getSchemeSpecificPart() : null);
|
||||
URI location = (codeSource != null) ? codeSource.getLocation().toURI() : null;
|
||||
String path = (location != null) ? location.getSchemeSpecificPart() : null;
|
||||
if (path == null) {
|
||||
throw new IllegalStateException("Unable to determine code source archive");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MainMethodRunner {
|
||||
*/
|
||||
public MainMethodRunner(String mainClass, String[] args) {
|
||||
this.mainClassName = mainClass;
|
||||
this.args = (args != null ? args.clone() : null);
|
||||
this.args = (args != null) ? args.clone() : null;
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
|
||||
@@ -438,9 +438,9 @@ public class PropertiesLauncher extends Launcher {
|
||||
return SystemPropertyUtils.resolvePlaceholders(this.properties, value);
|
||||
}
|
||||
}
|
||||
return (defaultValue != null
|
||||
return (defaultValue != null)
|
||||
? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue)
|
||||
: defaultValue);
|
||||
: defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,11 +33,11 @@ public class ByteArrayRandomAccessData implements RandomAccessData {
|
||||
private final long length;
|
||||
|
||||
public ByteArrayRandomAccessData(byte[] bytes) {
|
||||
this(bytes, 0, (bytes != null ? bytes.length : 0));
|
||||
this(bytes, 0, (bytes != null) ? bytes.length : 0);
|
||||
}
|
||||
|
||||
public ByteArrayRandomAccessData(byte[] bytes, long offset, long length) {
|
||||
this.bytes = (bytes != null ? bytes : new byte[0]);
|
||||
this.bytes = (bytes != null) ? bytes : new byte[0];
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
return read(b, 0, b != null ? b.length : 0);
|
||||
return read(b, 0, (b != null) ? b.length : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,7 +178,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
}
|
||||
if (b == null) {
|
||||
int rtn = file.read();
|
||||
moveOn(rtn != -1 ? 1 : 0);
|
||||
moveOn((rtn != -1) ? 1 : 0);
|
||||
return rtn;
|
||||
}
|
||||
else {
|
||||
@@ -194,7 +194,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
return (n <= 0 ? 0 : moveOn(cap(n)));
|
||||
return (n <= 0) ? 0 : moveOn(cap(n));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -145,11 +145,25 @@ final class AsciiBytes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.string == null) {
|
||||
this.string = new String(this.bytes, this.offset, this.length, UTF_8);
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
return this.string;
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj.getClass().equals(AsciiBytes.class)) {
|
||||
AsciiBytes other = (AsciiBytes) obj;
|
||||
if (this.length == other.length) {
|
||||
for (int i = 0; i < this.length; i++) {
|
||||
if (this.bytes[this.offset + i] != other.bytes[other.offset + i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,25 +207,11 @@ final class AsciiBytes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
public String toString() {
|
||||
if (this.string == null) {
|
||||
this.string = new String(this.bytes, this.offset, this.length, UTF_8);
|
||||
}
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj.getClass().equals(AsciiBytes.class)) {
|
||||
AsciiBytes other = (AsciiBytes) obj;
|
||||
if (this.length == other.length) {
|
||||
for (int i = 0; i < this.length; i++) {
|
||||
if (this.bytes[this.offset + i] != other.bytes[other.offset + i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return this.string;
|
||||
}
|
||||
|
||||
static String toString(byte[] bytes) {
|
||||
|
||||
@@ -103,7 +103,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
|
||||
@Override
|
||||
public boolean hasName(String name, String suffix) {
|
||||
return this.name.equals(new AsciiBytes(suffix != null ? name + suffix : name));
|
||||
return this.name.equals(new AsciiBytes((suffix != null) ? name + suffix : name));
|
||||
}
|
||||
|
||||
public boolean isDirectory() {
|
||||
|
||||
@@ -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.
|
||||
@@ -43,7 +43,7 @@ class CentralDirectoryParser {
|
||||
* Parse the source data, triggering {@link CentralDirectoryVisitor visitors}.
|
||||
* @param data the source data
|
||||
* @param skipPrefixBytes if prefix bytes should be skipped
|
||||
* @return The actual archive data without any prefix bytes
|
||||
* @return the actual archive data without any prefix bytes
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public RandomAccessData parse(RandomAccessData data, boolean skipPrefixBytes)
|
||||
|
||||
@@ -258,7 +258,7 @@ public class Handler extends URLStreamHandler {
|
||||
}
|
||||
|
||||
private int hashCode(String protocol, String file) {
|
||||
int result = (protocol != null ? protocol.hashCode() : 0);
|
||||
int result = (protocol != null) ? protocol.hashCode() : 0;
|
||||
int separatorIndex = file.indexOf(SEPARATOR);
|
||||
if (separatorIndex == -1) {
|
||||
return result + file.hashCode();
|
||||
@@ -327,7 +327,7 @@ public class Handler extends URLStreamHandler {
|
||||
String path = name.substring(FILE_PROTOCOL.length());
|
||||
File file = new File(URLDecoder.decode(path, "UTF-8"));
|
||||
Map<File, JarFile> cache = rootFileCache.get();
|
||||
JarFile result = (cache != null ? cache.get(file) : null);
|
||||
JarFile result = (cache != null) ? cache.get(file) : null;
|
||||
if (result == null) {
|
||||
result = new JarFile(file);
|
||||
addToRootFileCache(file, result);
|
||||
|
||||
@@ -71,7 +71,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader {
|
||||
@Override
|
||||
public Attributes getAttributes() throws IOException {
|
||||
Manifest manifest = this.jarFile.getManifest();
|
||||
return (manifest != null ? manifest.getAttributes(getName()) : null);
|
||||
return (manifest != null) ? manifest.getAttributes(getName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,7 +154,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
|
||||
@Override
|
||||
public Manifest getManifest() throws IOException {
|
||||
Manifest manifest = (this.manifest != null ? this.manifest.get() : null);
|
||||
Manifest manifest = (this.manifest != null) ? this.manifest.get() : null;
|
||||
if (manifest == null) {
|
||||
if (this.type == JarFileType.NESTED_DIRECTORY) {
|
||||
manifest = new JarFile(this.getRootJarFile()).getManifest();
|
||||
@@ -219,7 +219,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
if (ze instanceof JarEntry) {
|
||||
return this.entries.getInputStream((JarEntry) ze, access);
|
||||
}
|
||||
return getInputStream((ze != null ? ze.getName() : null), access);
|
||||
return getInputStream((ze != null) ? ze.getName() : null, access);
|
||||
}
|
||||
|
||||
InputStream getInputStream(String name, ResourceAccess access) throws IOException {
|
||||
|
||||
@@ -246,10 +246,10 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
boolean cacheEntry) {
|
||||
try {
|
||||
FileHeader cached = this.entriesCache.get(index);
|
||||
FileHeader entry = (cached != null ? cached
|
||||
FileHeader entry = (cached != null) ? cached
|
||||
: CentralDirectoryFileHeader.fromRandomAccessData(
|
||||
this.centralDirectoryData,
|
||||
this.centralDirectoryOffsets[index], this.filter));
|
||||
this.centralDirectoryOffsets[index], this.filter);
|
||||
if (CentralDirectoryFileHeader.class.equals(entry.getClass())
|
||||
&& type.equals(JarEntry.class)) {
|
||||
entry = new JarEntry(this.jarFile, (CentralDirectoryFileHeader) entry);
|
||||
@@ -280,7 +280,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
}
|
||||
|
||||
private AsciiBytes applyFilter(AsciiBytes name) {
|
||||
return (this.filter != null ? this.filter.apply(name) : name);
|
||||
return (this.filter != null) ? this.filter.apply(name) : name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -205,7 +205,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return this.jarFile.size();
|
||||
}
|
||||
JarEntry entry = getJarEntry();
|
||||
return (entry != null ? (int) entry.getSize() : -1);
|
||||
return (entry != null) ? (int) entry.getSize() : -1;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return -1;
|
||||
@@ -220,7 +220,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null);
|
||||
return (this.jarEntryName != null) ? this.jarEntryName.getContentType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,7 +242,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
}
|
||||
try {
|
||||
JarEntry entry = getJarEntry();
|
||||
return (entry != null ? entry.getTime() : 0);
|
||||
return (entry != null) ? entry.getTime() : 0;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return 0;
|
||||
@@ -388,8 +388,8 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
private String deduceContentType() {
|
||||
// Guess the content type, don't bother with streams as mark is not supported
|
||||
String type = (isEmpty() ? "x-java/jar" : null);
|
||||
type = (type != null ? type : guessContentTypeFromName(toString()));
|
||||
type = (type != null ? type : "content/unknown");
|
||||
type = (type != null) ? type : guessContentTypeFromName(toString());
|
||||
type = (type != null) ? type : "content/unknown";
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ class ZipInflaterInputStream extends InflaterInputStream {
|
||||
|
||||
private static int getInflaterBufferSize(long size) {
|
||||
size += 2; // inflater likes some space
|
||||
size = (size > 65536 ? 8192 : size);
|
||||
size = (size <= 0 ? 4096 : size);
|
||||
size = (size > 65536) ? 8192 : size;
|
||||
size = (size <= 0) ? 4096 : size;
|
||||
return (int) size;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils {
|
||||
if (propVal != null) {
|
||||
return propVal;
|
||||
}
|
||||
return (properties != null ? properties.getProperty(placeholderName) : null);
|
||||
return (properties != null) ? properties.getProperty(placeholderName) : null;
|
||||
}
|
||||
|
||||
public static String getProperty(String key) {
|
||||
|
||||
@@ -358,10 +358,11 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
private void addClasspath(List<String> args) throws MojoExecutionException {
|
||||
try {
|
||||
StringBuilder classpath = new StringBuilder();
|
||||
for (URL ele : getClassPathUrls()) {
|
||||
classpath = classpath
|
||||
.append((classpath.length() > 0 ? File.pathSeparator : "")
|
||||
+ new File(ele.toURI()));
|
||||
for (URL url : getClassPathUrls()) {
|
||||
if (classpath.length() > 0) {
|
||||
classpath.append(File.pathSeparator);
|
||||
}
|
||||
classpath.append(new File(url.toURI()));
|
||||
}
|
||||
getLog().debug("Classpath for forked process: " + classpath);
|
||||
args.add("-cp");
|
||||
@@ -481,7 +482,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
if (!(ex instanceof ThreadDeath)) {
|
||||
synchronized (this.monitor) {
|
||||
this.exception = (this.exception != null ? this.exception : ex);
|
||||
this.exception = (this.exception != null) ? this.exception : ex;
|
||||
}
|
||||
getLog().warn(ex);
|
||||
}
|
||||
@@ -511,7 +512,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
|
||||
LaunchRunner(String startClassName, String... args) {
|
||||
this.startClassName = startClassName;
|
||||
this.args = (args != null ? args : new String[] {});
|
||||
this.args = (args != null) ? args : new String[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
|
||||
String value = (String) entry.getValue();
|
||||
String existing = this.data.getProperty(name);
|
||||
this.data.setProperty(name,
|
||||
existing != null ? existing + "," + value : value);
|
||||
(existing != null) ? existing + "," + value : value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
|
||||
private File getTargetFile() {
|
||||
String classifier = (this.classifier != null ? this.classifier.trim() : "");
|
||||
String classifier = (this.classifier != null) ? this.classifier.trim() : "";
|
||||
if (classifier.length() > 0 && !classifier.startsWith("-")) {
|
||||
classifier = "-" + classifier;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
|
||||
private String removeLineBreaks(String description) {
|
||||
return (description != null ? description.replaceAll("\\s+", " ") : null);
|
||||
return (description != null) ? description.replaceAll("\\s+", " ") : null;
|
||||
}
|
||||
|
||||
private void putIfMissing(Properties properties, String key,
|
||||
|
||||
@@ -233,8 +233,8 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
|
||||
private ClassPathEntryFilter(Class<?> testClass) throws Exception {
|
||||
ClassPathExclusions exclusions = AnnotationUtils.findAnnotation(testClass,
|
||||
ClassPathExclusions.class);
|
||||
this.exclusions = (exclusions != null ? Arrays.asList(exclusions.value())
|
||||
: Collections.<String>emptyList());
|
||||
this.exclusions = (exclusions != null) ? Arrays.asList(exclusions.value())
|
||||
: Collections.<String>emptyList();
|
||||
}
|
||||
|
||||
private boolean isExcluded(URL url) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user