DomGarguilo commented on code in PR #4912:
URL: https://github.com/apache/accumulo/pull/4912#discussion_r1777541744


##########
core/src/main/java/org/apache/accumulo/core/fate/FateKey.java:
##########
@@ -168,4 +168,12 @@ private static Optional<ExternalCompactionId> 
deserializeCompactionId(FateKeyTyp
         throw new IllegalStateException("Unexpected FateInstanceType found " + 
type);
     }
   }
+
+  @Override
+  public String toString() {
+    return "[" + getClass().getSimpleName() + " FateKeyType:" + type
+        + (keyExtent.isPresent() ? ", KeyExtent:" + keyExtent.orElseThrow()
+            : ", ExternalCompactionID:" + compactionId.orElseThrow())
+        + "]";
+  }

Review Comment:
   Could use ToStringBuilder here. It makes it so we don't have to deal with 
formatting as much (like placement of spaces, brackets or commas).
   ```suggestion
     @Override
     public String toString() {
       var buf = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
       buf.append("FateKeyType", type);
       keyExtent.ifPresentOrElse(keyExtent -> buf.append("KeyExtent", 
keyExtent),
           () -> buf.append("ExternalCompactionID", compactionId.orElse(null)));
       return buf.toString();
     }
   ```
   
   This does slightly change the output but I think it looks fine. Here is the 
new output:
   ```
   
FateKey[FateKeyType=COMPACTION_COMMIT,ExternalCompactionID=ECID-1918a419-f4d1-4c91-bb1e-c9190ec56e55]
   
FateKey[FateKeyType=SPLIT,KeyExtent=MetaFateStoreFateIT_testCreateWithKeyInProgress0;zzz;aaa]
   ```
   and here is the original:
   ```
   [FateKey FateKeyType:COMPACTION_COMMIT, 
ExternalCompactionID:ECID-537f9fe4-4220-4238-9a2c-bc20b0dd4c59]
   [FateKey FateKeyType:SPLIT, 
KeyExtent:MetaFateStoreFateIT_testCreateWithKeyInProgress0;zzz;aaa]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to