Java Code Examples for com.google.common.base.Objects#ToStringHelper

The following examples show how to use com.google.common.base.Objects#ToStringHelper . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DedupQueue.java    From emodb with Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
    SortedQueue queue = _queue;
    Objects.ToStringHelper helper = Objects.toStringHelper(this);
    helper.add("name", _name);
    helper.add("#write", _eventStore.getSizeEstimate(_writeChannel, 1000));
    helper.add("#write-claims", _eventStore.getClaimCount(_writeChannel));
    helper.add("#dedup", (queue != null) ? queue.sizeEstimate() : "n/a");
    helper.add("#read", _eventStore.getSizeEstimate(_readChannel, 1000));
    helper.add("#read-claims", _eventStore.getClaimCount(_readChannel));
    if (_asyncFiller.isFilling()) {
        helper.addValue("FILLING");
        helper.add("idle", _asyncFiller.getConsecutiveNoops());
    }
    return helper.toString();
}
 
Example 2
Source File: MultiwayPoolBuilder.java    From multiway-pool with Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
  Objects.ToStringHelper s = Objects.toStringHelper(this);
  if (concurrencyLevel != UNSET_INT) {
    s.add("concurrencyLevel", concurrencyLevel);
  }
  if (maximumSize != UNSET_INT) {
    s.add("maximumSize", maximumSize);
  }
  if (maximumWeight != UNSET_INT) {
    s.add("maximumWeight", maximumWeight);
  }
  if (expireAfterWriteNanos != UNSET_INT) {
    s.add("expireAfterWrite", expireAfterWriteNanos + "ns");
  }
  if (expireAfterAccessNanos != UNSET_INT) {
    s.add("expireAfterAccess", expireAfterAccessNanos + "ns");
  }
  if (lifecycle != null) {
    s.addValue("resourceLifecycle");
  }
  return s.toString();
}
 
Example 3
Source File: TestResourceAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestResourceAuthorizationProvider(Subject subject,
    Server server, Database database, Table table,
    Set<? extends Action> privileges, boolean expected) throws Exception {
  List<Authorizable> authzHierarchy = Arrays.asList(new Authorizable[] {
      server, database, table
  });
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
  helper.add("Subject", subject).add("Server", server).add("DB", database)
  .add("Table", table).add("Privileges", privileges).add("authzHierarchy", authzHierarchy);
  LOGGER.info("Running with " + helper.toString());
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authzHierarchy, privileges, ActiveRoleSet.ALL));
  LOGGER.info("Passed " + helper.toString());
}
 
Example 4
Source File: TimeDomain.java    From kite with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
  Objects.ToStringHelper helper = Objects.toStringHelper(this);
  if (lower.length > 0) {
    helper.add("lower", Arrays.toString(lower));
  }
  if (upper.length > 0) {
    helper.add("upper", Arrays.toString(upper));
  }
  return helper.toString();
}
 
Example 5
Source File: DatasetDescriptor.java    From kite with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
  Objects.ToStringHelper helper = Objects.toStringHelper(this)
      .add("format", format)
      .add("schema", schema)
      .add("location", location)
      .add("properties", properties)
      .add("partitionStrategy", partitionStrategy)
      .add("compressionType", compressionType);
  if (isColumnMapped()) {
    helper.add("columnMapping", columnMappings);
  }
  return helper.toString();
}
 
Example 6
Source File: TestSearchAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestResourceAuthorizationProvider(Subject subject,
    Collection collection,
    Set<? extends Action> privileges, boolean expected) throws Exception {
  List<Authorizable> authzHierarchy = Arrays.asList(new Authorizable[] {
      collection
  });
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
  helper.add("Subject", subject).add("Collection", collection)
    .add("Privileges", privileges).add("authzHierarchy", authzHierarchy);
  LOGGER.info("Running with " + helper.toString());
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authzHierarchy, privileges, ActiveRoleSet.ALL));
  LOGGER.info("Passed " + helper.toString());
}
 
Example 7
Source File: TestKafkaAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestResourceAuthorizationProvider(Subject subject, List<? extends Authorizable> authorizableHierarchy,
    Set<? extends Action> actions, boolean expected) throws Exception {
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
  helper.add("Subject", subject).add("authzHierarchy", authorizableHierarchy).add("action", actions);
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authorizableHierarchy, actions, ActiveRoleSet.ALL));
}
 
Example 8
Source File: TestSqoopAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestResourceAuthorizationProvider(Subject subject, List<? extends Authorizable> authorizableHierarchy,
    Set<? extends Action> actions, boolean expected) throws Exception {
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
  helper.add("Subject", subject).add("authzHierarchy", authorizableHierarchy).add("action", actions);
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authorizableHierarchy, actions, ActiveRoleSet.ALL));
}
 
Example 9
Source File: TestIndexerAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestResourceAuthorizationProvider(Subject subject,
    Indexer indexer,
    Set<? extends Action> privileges, boolean expected) throws Exception {
  List<Authorizable> authzHierarchy = Arrays.asList(new Authorizable[] {
      indexer
  });
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
  helper.add("Subject", subject).add("Indexer", indexer)
    .add("Privileges", privileges).add("authzHierarchy", authzHierarchy);
  LOGGER.info("Running with " + helper.toString());
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authzHierarchy, privileges, ActiveRoleSet.ALL));
  LOGGER.info("Passed " + helper.toString());
}
 
Example 10
Source File: AndroidImageReaderProxy.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
    Objects.ToStringHelper tsh;
    synchronized (mLock)
    {
        tsh = Objects.toStringHelper(mDelegate);
    }
    return tsh.add("width", getWidth())
            .add("height", getHeight())
            .add("format", imageFormatToString(getImageFormat()))
            .toString();
}
 
Example 11
Source File: TestResourceAuthorizationProviderGeneralCases.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private void doTestAuthorizables(
    Subject subject, Set<? extends Action> privileges, boolean expected,
    Authorizable... authorizables) throws Exception {
  List<Authorizable> authzHierarchy = Arrays.asList(authorizables);
  Objects.ToStringHelper helper = Objects.toStringHelper("TestParameters");
    helper.add("authorizables", authzHierarchy).add("Privileges", privileges);
  LOGGER.info("Running with " + helper.toString());
  Assert.assertEquals(helper.toString(), expected,
      authzProvider.hasAccess(subject, authzHierarchy, privileges, ActiveRoleSet.ALL));
  LOGGER.info("Passed " + helper.toString());
}
 
Example 12
Source File: ShiroConfiguration.java    From dw-shiro-bundle with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * If wishing to add additional fields to the {@link #toString()} return values, subclasses may override this method and call super() and then add their own parts to the result before returing it.
 * @return an {@link Objects.ToStringHelper} instance populated with the class name and the name:value pairs of the instance's fields
 */
protected Objects.ToStringHelper toStringHelper() {
    return Objects.toStringHelper(this.getClass().getSimpleName())
            .add("enabled (enabled)", enabled)
            .add("securedUrlPattern (secured_url_pattern)", securedUrlPattern)
            .add("dropwizardSessionHandler (dropwizard_session_handler)", dropwizardSessionHandler)
            ;
}
 
Example 13
Source File: TftpRequestPacket.java    From tftp4j with Apache License 2.0 5 votes vote down vote up
@Override
protected Objects.ToStringHelper toStringHelper() {
    return super.toStringHelper()
            .add("filename", getFilename())
            .add("mode", getMode())
            .add("blockSize", getBlockSize());
}
 
Example 14
Source File: TftpErrorPacket.java    From tftp4j with Apache License 2.0 4 votes vote down vote up
@Override
protected Objects.ToStringHelper toStringHelper() {
    return super.toStringHelper().add("errorCode", getErrorCode()).add("errorMessage", getErrorMessage());
}
 
Example 15
Source File: TftpPacket.java    From tftp4j with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected Objects.ToStringHelper toStringHelper() {
    return Objects.toStringHelper(this).add("opcode", getOpcode());
}
 
Example 16
Source File: TftpDataPacket.java    From tftp4j with Apache License 2.0 4 votes vote down vote up
@Override
protected Objects.ToStringHelper toStringHelper() {
    return super.toStringHelper()
            .add("blockNumber", (int) getBlockNumber())
            .add("data", data);
}
 
Example 17
Source File: TftpAckPacket.java    From tftp4j with Apache License 2.0 4 votes vote down vote up
@Override
protected Objects.ToStringHelper toStringHelper() {
    return super.toStringHelper().add("blockNumber", (int) getBlockNumber());
}
 
Example 18
Source File: Field.java    From occurrence with Apache License 2.0 4 votes vote down vote up
protected Objects.ToStringHelper toStringHelper() {
  return Objects.toStringHelper(this).omitNullValues();
}