下面列出了怎么用com.google.common.base.MoreObjects的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("name", name)
.add("icon", icon)
.add("description", description)
.add("organizationId", organizationId)
.add("colour", colour)
.add("typeCode", typeCode)
.add("initialize", initialize)
.add("objectVersionNumber", objectVersionNumber)
.add("stateMachineName", stateMachineName)
.add("stateMachineId", stateMachineId)
.toString();
}
/**
* Construct a readable string representation for this Book instance.
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return MoreObjects.toStringHelper(this) //
.add("id", getId()) //
.add("title", getTitle()) //
.add("summary", getSummary()) //
.add("extractBinary", getExtractBinary()) //
.add("extractFileName", getExtractFileName()) //
.add("extractContentType", getExtractContentType()) //
.add("extractSize", getExtractSize()) //
.add("publicationDate", getPublicationDate()) //
.add("bestSeller", getBestSeller()) //
.add("price", getPrice()) //
.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues();
helper.add("options", options);
if (maxNumEventLoopsPerHttp1Endpoint > 0) {
helper.add("maxNumEventLoopsPerHttp1Endpoint", maxNumEventLoopsPerHttp1Endpoint);
}
if (maxNumEventLoopsPerEndpoint > 0) {
helper.add("maxNumEventLoopsPerEndpoint", maxNumEventLoopsPerEndpoint);
}
if (!maxNumEventLoopsFunctions.isEmpty()) {
helper.add("maxNumEventLoopsFunctions", maxNumEventLoopsFunctions);
}
return helper.toString();
}
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues()
.add("name", name)
.add("value", !value.isEmpty() ? value : "<EMPTY>")
.add("valueQuoted", valueQuoted)
.add("domain", domain)
.add("path", path);
if (maxAge != Cookie.UNDEFINED_MAX_AGE) {
helper.add("maxAge", maxAge);
}
if (secure) {
helper.addValue("secure");
}
if (httpOnly) {
helper.addValue("httpOnly");
}
helper.add("sameSite", sameSite);
return helper.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("name", name)
.add("description", description)
.add("spiffeId", spiffeId)
.add("createdAt", createdAt)
.add("createdBy", createdBy)
.add("updatedAt", updatedAt)
.add("updatedBy", updatedBy)
.add("lastSeen", lastSeen)
.add("expiration", expiration)
.add("enabled", enabled)
.add("automationAllowed", automationAllowed)
.toString();
}
private static void compareItemSchemaArray(
final ArraySchema original, final ArraySchema update, final SchemaDiffState state) {
final List<Schema> emptyList = ImmutableList.of();
final List<Schema> originalSchemas = MoreObjects.firstNonNull(original.getItemSchemas(), emptyList);
final List<Schema> updateSchemas = MoreObjects.firstNonNull(update.getItemSchemas(), emptyList);
if (originalSchemas.size() != updateSchemas.size()) {
state.addChange(NUMBER_OF_ITEMS_CHANGED);
} else {
final Iterator<Schema> originalIterator = originalSchemas.iterator();
final Iterator<Schema> updateIterator = updateSchemas.iterator();
int index = 0;
while (originalIterator.hasNext()) {
state.runOnPath("items/" + index, () -> {
SchemaDiff.recursiveCheck(originalIterator.next(), updateIterator.next(), state);
});
index += 1;
}
}
}
@Test
public void testToString(){
String userId = "dudes";
String userName = "The Dude";
String userEmail = "[email protected]";
User user = new User()
.setId(1L)
.setUserId(userId)
.setName(userName)
.setEmail(userEmail);
String exp = MoreObjects.toStringHelper(User.class)
.add("ID", 1L)
.add("User ID", userId)
.add("Name", userName)
.add("Email", userEmail)
.toString();
Assert.assertEquals("Testing toString()", exp, user.toString());
}
@Override
public String toString()
{
// NOTE: try keeping this string short...
final String tableName = getDocument().getEntityDescriptor().getTableNameOrNull();
final String fieldName = getFieldName();
final String fieldNameFQ = tableName == null ? fieldName : tableName + "." + fieldName;
return MoreObjects.toStringHelper(this)
.add("fieldName", fieldNameFQ)
// .add("documentPath", getDocumentPath())
.add("value", _value)
.add("initalValue", _initialValue)
// .add("mandatory", _mandatory)
// .add("readonly", _readonly)
// .add("displayed", _displayed)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("msg", msg)
.add("recipients", recipients)
.add("name", name)
.add("sender", sender)
.add("state", state)
.add("errorMessage", errorMessage)
.add("lastUpdated", lastUpdated)
.add("attributes", attributes)
.add("size", size)
.add("remoteAddr", remoteAddr)
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.add("caption", caption)
.add("sections-count", sectionBuilders.size())
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.addValue(values.get(this))
.toString();
}
@Override
public String toString() {
return MoreObjects
.toStringHelper(this)
.add("attachment", attachment)
.add("name", name)
.add("cid", cid)
.add("isInline", isInline)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("column", columnName)
.add("expression", expression)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", name)
.add("path", path)
.add("description", description)
.add("content", content)
.add("query", query)
.toString();
}
@Override
public String toString(){
return MoreObjects.toStringHelper(this)
.add("ID", id)
.add("Instance Application", application)
.add("Instance Name", name)
.add("Instance ID", instanceId)
.add("Instance IP", ip)
.add("Status", status)
.add("Platform", platform)
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.add("caption", caption)
.add("processId", processId)
.add("quickAction", quickAction)
.add("defaultQuickAction", defaultQuickAction)
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.add("rootNode", rootNode)
.add("version", version)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("enabled", enabled)
.add("port", port)
.add("host", host)
.add("metricCategories", metricCategories)
.add("pushEnabled", pushEnabled)
.add("pushPort", pushPort)
.add("pushHost", pushHost)
.add("pushInterval", pushInterval)
.add("prometheusJob", prometheusJob)
.add("hostsAllowlist", hostsAllowlist)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("schema", schema)
.add("likePattern", likePattern.toString())
.add("whereExpression", whereExpression.toString())
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper( this )
.add( "name", name )
.add( "nodeType", nodeType )
.add( "parent", (parent != null ? parent.getName() : null) )
.add( "namespace", namespace )
.add( "comment", comment )
.add( "children", children )
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("userId", userId)
.add("email", email)
.add("name", name)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("maxAttempts", maxAttempts)
.add("initialBackoffNanos", initialBackoffNanos)
.add("maxBackoffNanos", maxBackoffNanos)
.add("backoffMultiplier", backoffMultiplier)
.add("retryableStatusCodes", retryableStatusCodes)
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.add("type", type)
.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.omitNullValues()
.add("id", id)
.add("targetIndicatorItems", _targetIndicatorItemsById.isEmpty() ? null : _targetIndicatorItemsById)
.add("kpiItemsById", _kpiItemsById.isEmpty() ? null : _kpiItemsById)
.toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).omitNullValues()
.add("content", content())
.add("contentType", contentType())
.add("lastModified", DateFormatter.format(new Date(attrs.lastModifiedMillis())))
.add("dateEnabled", isDateEnabled())
.add("lastModifiedEnabled", isLastModifiedEnabled())
.add("headers", headers())
.toString();
}
/** A string representation of the status useful for debugging. */
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("code", code.name())
.add("description", description)
.add("cause", cause != null ? getStackTraceAsString(cause) : cause)
.toString();
}
@Override
public String toString() {
final ToStringHelper stringHelper = MoreObjects.toStringHelper(this)
.add("summary", summary());
if (!isNullOrEmpty(detail)) {
stringHelper.add("detail", detail());
stringHelper.add("markup", markup());
}
return stringHelper.toString();
}
@Override
public String toString()
{
return MoreObjects.toStringHelper(this)
.add("initialDelayMs", initialDelayMs)
.add("maxDelayMs", maxDelayMs)
.add("decrease", decrease)
.add("increase", increase)
.add("delay", delay)
.add("state", state)
.toString();
}
public String toMinimalString()
{
return MoreObjects.toStringHelper( this )
.add( "imported", imported )
.add( "updated", updated )
.add( "deleted", deleted )
.add( "ignored", ignored ).toString();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("path", path)
.add("line", line)
.add("column", column)
.add("code", code)
.toString();
}