Skip to content

Commit

Permalink
Delete getDisplaySubject().
Browse files Browse the repository at this point in the history
RELNOTES=Removed `getDisplaySubject()`. Callers should use `actualAsString()`; overriders should use `actualCustomStringRepresentation()`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185838490
  • Loading branch information
cpovirk authored and ronshapiro committed Feb 15, 2018
1 parent e249740 commit 47ea976
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions core/src/main/java/com/google/common/truth/Subject.java
Expand Up @@ -279,24 +279,6 @@ protected final T actual() {
return getSubject();
}

/** @deprecated Prefer {@code #actualAsString()} for display-formatted access to the subject. */
@Deprecated
protected String getDisplaySubject() {
// TODO(cgruber) migrate people from this method once no one is subclassing it.
String formatted = actualCustomStringRepresentation();
if (customName != null) {
// Covers some rare cases where a type might return "" from their custom formatter.
// This is actually pretty terrible, as it comes from subjects overriding (formerly)
// getDisplaySubject() in cases of .named() to make it not prefixing but replacing.
// That goes against the stated contract of .named(). Once displayedAs() is in place,
// we can rip this out and callers can use that instead.
// TODO(cgruber)
return customName + (formatted.isEmpty() ? "" : " (<" + formatted + ">)");
} else {
return "<" + formatted + ">";
}
}

/**
* Returns a string representation of the actual value. This will either be the toString() of the
* value or a prefixed "name" along with the string representation.
Expand All @@ -311,7 +293,18 @@ protected String getDisplaySubject() {
* use this from FailureMetadata, at least in the short term, for better or for worse.
*/
protected final String actualAsString() {
return getDisplaySubject();
String formatted = actualCustomStringRepresentation();
if (customName != null) {
// Covers some rare cases where a type might return "" from their custom formatter.
// This is actually pretty terrible, as it comes from subjects overriding (formerly)
// getDisplaySubject() in cases of .named() to make it not prefixing but replacing.
// That goes against the stated contract of .named(). Once displayedAs() is in place,
// we can rip this out and callers can use that instead.
// TODO(cgruber)
return customName + (formatted.isEmpty() ? "" : " (<" + formatted + ">)");
} else {
return "<" + formatted + ">";
}
}

/**
Expand Down

0 comments on commit 47ea976

Please sign in to comment.