Skip to content

Commit

Permalink
toString updates
Browse files Browse the repository at this point in the history
Standardize on toString/hash/equals formats

further toString unification

missed one more

Fix toString outside of SingularityBase

Fix toString outside of SingularityBase
  • Loading branch information
ssalinas committed Feb 27, 2017
1 parent c9900f2 commit d07e783
Show file tree
Hide file tree
Showing 118 changed files with 1,572 additions and 1,160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public boolean equals(Object other) {

@Override
public String toString() {
return "Artifact [name=" + name + ", filename=" + filename + ", md5sum=" + md5sum + ", targetFolderRelativeToTask=" + targetFolderRelativeToTask + "]";
return "Artifact{" +
"name='" + name + '\'' +
", filename='" + filename + '\'' +
", md5sum=" + md5sum +
", targetFolderRelativeToTask=" + targetFolderRelativeToTask +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public byte[] getContent() {
return content;
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), content);
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -44,14 +39,19 @@ public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}

EmbeddedArtifact that = (EmbeddedArtifact) o;
return Arrays.equals(content, that.content);
}

@Override
public String toString() {
return "EmbeddedArtifact [parent=" + super.toString() + "]";
public int hashCode() {
return Objects.hash(super.hashCode(), content);
}

@Override
public String toString() {
return "EmbeddedArtifact{" +
"content=" + Arrays.toString(content) +
"} " + super.toString();
}
}
40 changes: 19 additions & 21 deletions SingularityBase/src/main/java/com/hubspot/deploy/ExecutorData.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.hubspot.mesos.JavaUtils;
import com.hubspot.singularity.executor.SingularityExecutorLogrotateFrequency;
Expand Down Expand Up @@ -152,25 +151,24 @@ public Optional<SingularityExecutorLogrotateFrequency> getLogrotateFrequency() {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("cmd", cmd)
.add("embeddedArtifacts", embeddedArtifacts)
.add("externalArtifacts", externalArtifacts)
.add("s3Artifacts", s3Artifacts)
.add("successfulExitCodes", successfulExitCodes)
.add("runningSentinel", runningSentinel)
.add("user", user)
.add("extraCmdLineArgs", extraCmdLineArgs)
.add("loggingTag", loggingTag)
.add("loggingExtraFields", loggingExtraFields)
.add("sigKillProcessesAfterMillis", sigKillProcessesAfterMillis)
.add("maxTaskThreads", maxTaskThreads)
.add("preserveTaskSandboxAfterFinish", preserveTaskSandboxAfterFinish)
.add("maxOpenFiles", maxOpenFiles)
.add("skipLogrotateAndCompress", skipLogrotateAndCompress)
.add("s3ArtifactSignatures", s3ArtifactSignatures)
.add("logrotateFrequency", logrotateFrequency)
.add("builder", toBuilder())
.toString();
return "ExecutorData{" +
"cmd='" + cmd + '\'' +
", embeddedArtifacts=" + embeddedArtifacts +
", externalArtifacts=" + externalArtifacts +
", s3Artifacts=" + s3Artifacts +
", successfulExitCodes=" + successfulExitCodes +
", runningSentinel=" + runningSentinel +
", user=" + user +
", extraCmdLineArgs=" + extraCmdLineArgs +
", loggingTag=" + loggingTag +
", loggingExtraFields=" + loggingExtraFields +
", sigKillProcessesAfterMillis=" + sigKillProcessesAfterMillis +
", maxTaskThreads=" + maxTaskThreads +
", preserveTaskSandboxAfterFinish=" + preserveTaskSandboxAfterFinish +
", maxOpenFiles=" + maxOpenFiles +
", skipLogrotateAndCompress=" + skipLogrotateAndCompress +
", s3ArtifactSignatures=" + s3ArtifactSignatures +
", logrotateFrequency=" + logrotateFrequency +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,24 @@ public ExecutorDataBuilder setLogrotateFrequency(Optional<SingularityExecutorLog

@Override
public String toString() {
return "ExecutorDataBuilder[" +
"cmd='" + cmd + '\'' +
", embeddedArtifacts=" + embeddedArtifacts +
", externalArtifacts=" + externalArtifacts +
", s3Artifacts=" + s3Artifacts +
", successfulExitCodes=" + successfulExitCodes +
", runningSentinel=" + runningSentinel +
", user=" + user +
", extraCmdLineArgs=" + extraCmdLineArgs +
", loggingTag=" + loggingTag +
", loggingExtraFields=" + loggingExtraFields +
", sigKillProcessesAfterMillis=" + sigKillProcessesAfterMillis +
", maxTaskThreads=" + maxTaskThreads +
", preserveTaskSandboxAfterFinish=" + preserveTaskSandboxAfterFinish +
", maxOpenFiles=" + maxOpenFiles +
", skipLogrotateAndCompress=" + skipLogrotateAndCompress +
", s3ArtifactSignatures=" + s3ArtifactSignatures +
", logrotateFrequency=" + logrotateFrequency +
']';
return "ExecutorDataBuilder{" +
"cmd='" + cmd + '\'' +
", embeddedArtifacts=" + embeddedArtifacts +
", externalArtifacts=" + externalArtifacts +
", s3Artifacts=" + s3Artifacts +
", successfulExitCodes=" + successfulExitCodes +
", runningSentinel=" + runningSentinel +
", user=" + user +
", extraCmdLineArgs=" + extraCmdLineArgs +
", loggingTag=" + loggingTag +
", loggingExtraFields=" + loggingExtraFields +
", sigKillProcessesAfterMillis=" + sigKillProcessesAfterMillis +
", maxTaskThreads=" + maxTaskThreads +
", preserveTaskSandboxAfterFinish=" + preserveTaskSandboxAfterFinish +
", maxOpenFiles=" + maxOpenFiles +
", skipLogrotateAndCompress=" + skipLogrotateAndCompress +
", s3ArtifactSignatures=" + s3ArtifactSignatures +
", logrotateFrequency=" + logrotateFrequency +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public boolean equals(Object other) {

@Override
public String toString() {
return "ExternalArtifact [url=" + url + ", parent=" + super.toString() + "]";
return "ExternalArtifact{" +
"url='" + url + '\'' +
"} " + super.toString();
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.hubspot.deploy;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.hubspot.singularity.HealthcheckProtocol;
import com.wordnik.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -123,37 +122,39 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
HealthcheckOptions options = (HealthcheckOptions) o;
return Objects.equal(uri, options.uri) &&
Objects.equal(portIndex, options.portIndex) &&
Objects.equal(portNumber, options.portNumber) &&
Objects.equal(protocol, options.protocol) &&
Objects.equal(startupTimeoutSeconds, options.startupTimeoutSeconds) &&
Objects.equal(startupDelaySeconds, options.startupDelaySeconds) &&
Objects.equal(startupIntervalSeconds, options.startupIntervalSeconds) &&
Objects.equal(intervalSeconds, options.intervalSeconds) &&
Objects.equal(responseTimeoutSeconds, options.responseTimeoutSeconds) &&
Objects.equal(maxRetries, options.maxRetries);
HealthcheckOptions that = (HealthcheckOptions) o;
return Objects.equals(uri, that.uri) &&
Objects.equals(portIndex, that.portIndex) &&
Objects.equals(portNumber, that.portNumber) &&
Objects.equals(protocol, that.protocol) &&
Objects.equals(startupTimeoutSeconds, that.startupTimeoutSeconds) &&
Objects.equals(startupDelaySeconds, that.startupDelaySeconds) &&
Objects.equals(startupIntervalSeconds, that.startupIntervalSeconds) &&
Objects.equals(intervalSeconds, that.intervalSeconds) &&
Objects.equals(responseTimeoutSeconds, that.responseTimeoutSeconds) &&
Objects.equals(maxRetries, that.maxRetries) &&
Objects.equals(failureStatusCodes, that.failureStatusCodes);
}

@Override
public int hashCode() {
return Objects.hashCode(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries);
return Objects.hash(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes);
}

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("uri", uri)
.add("portIndex", portIndex)
.add("portNumber", portNumber)
.add("protocol", protocol)
.add("startupTimeoutSeconds", startupTimeoutSeconds)
.add("startupDelaySeconds", startupDelaySeconds)
.add("startupIntervalSeconds", startupIntervalSeconds)
.add("intervalSeconds", intervalSeconds)
.add("responseTimeoutSeconds", responseTimeoutSeconds)
.add("maxRetries", maxRetries)
.toString();
return "HealthcheckOptions{" +
"uri='" + uri + '\'' +
", portIndex=" + portIndex +
", portNumber=" + portNumber +
", protocol=" + protocol +
", startupTimeoutSeconds=" + startupTimeoutSeconds +
", startupDelaySeconds=" + startupDelaySeconds +
", startupIntervalSeconds=" + startupIntervalSeconds +
", intervalSeconds=" + intervalSeconds +
", responseTimeoutSeconds=" + responseTimeoutSeconds +
", maxRetries=" + maxRetries +
", failureStatusCodes=" + failureStatusCodes +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.hubspot.deploy;

import java.util.List;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.hubspot.singularity.HealthcheckProtocol;

Expand Down Expand Up @@ -147,37 +147,39 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
HealthcheckOptionsBuilder options = (HealthcheckOptionsBuilder) o;
return Objects.equal(uri, options.uri) &&
Objects.equal(portIndex, options.portIndex) &&
Objects.equal(portNumber, options.portNumber) &&
Objects.equal(protocol, options.protocol) &&
Objects.equal(startupTimeoutSeconds, options.startupTimeoutSeconds) &&
Objects.equal(startupDelaySeconds, options.startupDelaySeconds) &&
Objects.equal(startupIntervalSeconds, options.startupIntervalSeconds) &&
Objects.equal(intervalSeconds, options.intervalSeconds) &&
Objects.equal(responseTimeoutSeconds, options.responseTimeoutSeconds) &&
Objects.equal(maxRetries, options.maxRetries);
HealthcheckOptionsBuilder that = (HealthcheckOptionsBuilder) o;
return Objects.equals(uri, that.uri) &&
Objects.equals(portIndex, that.portIndex) &&
Objects.equals(portNumber, that.portNumber) &&
Objects.equals(protocol, that.protocol) &&
Objects.equals(startupTimeoutSeconds, that.startupTimeoutSeconds) &&
Objects.equals(startupDelaySeconds, that.startupDelaySeconds) &&
Objects.equals(startupIntervalSeconds, that.startupIntervalSeconds) &&
Objects.equals(intervalSeconds, that.intervalSeconds) &&
Objects.equals(responseTimeoutSeconds, that.responseTimeoutSeconds) &&
Objects.equals(maxRetries, that.maxRetries) &&
Objects.equals(failureStatusCodes, that.failureStatusCodes);
}

@Override
public int hashCode() {
return Objects.hashCode(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries);
return Objects.hash(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes);
}

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("uri", uri)
.add("portIndex", portIndex)
.add("portNumber", portNumber)
.add("protocol", protocol)
.add("startupTimeoutSeconds", startupTimeoutSeconds)
.add("startupDelaySeconds", startupDelaySeconds)
.add("startupIntervalSeconds", startupIntervalSeconds)
.add("intervalSeconds", intervalSeconds)
.add("responseTimeoutSeconds", responseTimeoutSeconds)
.add("maxRetries", maxRetries)
.toString();
return "HealthcheckOptionsBuilder{" +
"uri='" + uri + '\'' +
", portIndex=" + portIndex +
", portNumber=" + portNumber +
", protocol=" + protocol +
", startupTimeoutSeconds=" + startupTimeoutSeconds +
", startupDelaySeconds=" + startupDelaySeconds +
", startupIntervalSeconds=" + startupIntervalSeconds +
", intervalSeconds=" + intervalSeconds +
", responseTimeoutSeconds=" + responseTimeoutSeconds +
", maxRetries=" + maxRetries +
", failureStatusCodes=" + failureStatusCodes +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public int hashCode() {

@Override
public String toString() {
return "RemoteArtifact [filesize=" + filesize + ", parent=" + super.toString() + "]";
return "RemoteArtifact{" +
"filesize=" + filesize +
"} " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return "S3Artifact [s3Bucket=" + s3Bucket + ", s3ObjectKey=" + s3ObjectKey + ", parent=" + super.toString() + "]";
return "S3Artifact{" +
"s3Bucket='" + s3Bucket + '\'' +
", s3ObjectKey='" + s3ObjectKey + '\'' +
"} " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public int hashCode() {

@Override
public String toString() {
return "S3ArtifactSignature [artifactFilename=" + artifactFilename + ", parent=" + super.toString() + "]";
return "S3ArtifactSignature{" +
"artifactFilename='" + artifactFilename + '\'' +
"} " + super.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public int compare(Entry<K, Counter> o1, Entry<K, Counter> o2) {

@Override
public String toString() {
return "CounterMap [map=" + map + "]";
return "CounterMap{" +
"map=" + map +
'}';
}

}
20 changes: 10 additions & 10 deletions SingularityBase/src/main/java/com/hubspot/mesos/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ public double getDiskMb() {
return diskMb;
}

@Override
public String toString() {
return "Resources[" +
"cpus=" + cpus +
", memoryMb=" + memoryMb +
", numPorts=" + numPorts +
", diskMb=" + diskMb +
']';
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -79,4 +69,14 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(cpus, memoryMb, numPorts, diskMb);
}

@Override
public String toString() {
return "Resources{" +
"cpus=" + cpus +
", memoryMb=" + memoryMb +
", numPorts=" + numPorts +
", diskMb=" + diskMb +
'}';
}
}
Loading

1 comment on commit d07e783

@tpetr
Copy link
Contributor

@tpetr tpetr commented on d07e783 Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

Please sign in to comment.