本文整理了Java中java.util.Objects.toString()
方法的一些代码示例,展示了Objects.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.toString()
方法的具体详情如下:
包路径:java.util.Objects
类名称:Objects
方法名:toString
[英]Returns "null" for null or o.toString().
[中]为null或o.toString()返回“null”。
代码示例来源:origin: MovingBlocks/Terasology
@Override
public String toString(T value) {
return Objects.toString(value);
}
}
代码示例来源:origin: neo4j/neo4j
private static String getContext( WatchEvent<?> watchEvent )
{
return Objects.toString( watchEvent.context(), StringUtils.EMPTY );
}
}
代码示例来源:origin: square/okhttp
@Override public String toString() {
if (!tls) {
return "ConnectionSpec()";
}
return "ConnectionSpec("
+ "cipherSuites=" + Objects.toString(cipherSuites(), "[all enabled]")
+ ", tlsVersions=" + Objects.toString(tlsVersions(), "[all enabled]")
+ ", supportsTlsExtensions=" + supportsTlsExtensions
+ ")";
}
代码示例来源:origin: MovingBlocks/Terasology
@Override
public String getString(T value) {
if (translationSystem == null) {
return Objects.toString(value);
} else {
return translationSystem.translate(Objects.toString(value));
}
}
}
代码示例来源:origin: apache/incubator-druid
@Override
@Nullable
public String apply(@Nullable Object value)
{
return apply(Objects.toString(value, null));
}
代码示例来源:origin: SonarSource/sonarqube
private void appendContext(StringBuilder sb) {
for (Map.Entry<String, Object> entry : context.entrySet()) {
if (sb.length() > 0) {
sb.append(CONTEXT_SEPARATOR);
}
sb.append(entry.getKey()).append("=").append(Objects.toString(entry.getValue()));
}
}
代码示例来源:origin: SonarSource/sonarqube
private void appendContext(StringBuilder sb) {
for (Map.Entry<String, Object> entry : context.entrySet()) {
if (sb.length() > 0) {
sb.append(CONTEXT_SEPARATOR);
}
sb.append(entry.getKey()).append("=").append(Objects.toString(entry.getValue()));
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Set the value of a system property.
* <p>
* The name of the system property is computed based on the provided class and local name.
*
* @param location the class that owns the flag.
* @param name the local name of the flag.
* @param value the value to assign to the system property.
*/
public static void set( Class<?> location, String name, Object value )
{
System.setProperty( name( location, name ), Objects.toString( value ) );
}
代码示例来源:origin: SonarSource/sonarqube
static String format(String pattern, Object... args) {
String result = pattern;
for (Object arg : args) {
result = StringUtils.replaceOnce(result, "{}", Objects.toString(arg));
}
return result;
}
}
代码示例来源:origin: apache/hbase
/**
* Dumps all cells of the segment into the given log
*/
void dump(Logger log) {
for (Cell cell: getCellSet()) {
log.debug(Objects.toString(cell));
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public ProtobufSystemInfo.Section toProtobuf() {
ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
protobuf.setName(name);
Map<Object, Object> sortedProperties = new TreeMap<>(System.getProperties());
for (Map.Entry<Object, Object> systemProp : sortedProperties.entrySet()) {
if (systemProp.getValue() != null) {
setAttribute(protobuf, Objects.toString(systemProp.getKey()), Objects.toString(systemProp.getValue()));
}
}
return protobuf.build();
}
}
代码示例来源:origin: neo4j/neo4j
/**
* Helps creating a JVM parameter for setting a feature toggle of an arbitrary type.
* Given value will be converted to string using {@link Objects#toString(Object)} method.
*
* @param location the class that owns the flag.
* @param name the local name of the flag.
* @param value the value to assign to the feature toggle.
* @return the parameter to pass to the command line of the forked JVM.
*/
public static String toggle( Class<?> location, String name, Object value )
{
return toggle( name( location, name ), Objects.toString( value ) );
}
代码示例来源:origin: apache/hbase
/**
* @param description description of the files for logging
* @param storeFiles the status of the files to log
*/
private void logFiles(String description, FileStatus[] storeFiles) {
LOG.debug("Current " + description + ": ");
for (FileStatus file : storeFiles) {
LOG.debug(Objects.toString(file.getPath()));
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void close() throws IOException
{
// We're done, do some final logging about it
long totalTimeMillis = currentTimeMillis() - startTime;
DataStatistics state = getState( DataStatistics.class );
String additionalInformation = Objects.toString( state, "Data statistics is not available." );
executionMonitor.done( successful, totalTimeMillis, format( "%n%s%nPeak memory usage: %s", additionalInformation, bytes( peakMemoryUsage ) ) );
log.info( "Import completed successfully, took " + duration( totalTimeMillis ) + ". " + additionalInformation );
closeAll( nodeRelationshipCache, nodeLabelsCache, idMapper );
}
代码示例来源:origin: ben-manes/caffeine
/** Free memory by clearing unused resources after test execution. */
private void cleanUp(ITestResult testResult) {
Object[] params = testResult.getParameters();
for (int i = 0; i < params.length; i++) {
Object param = params[i];
if ((param instanceof AsyncLoadingCache<?, ?>) || (param instanceof Cache<?, ?>)
|| (param instanceof Map<?, ?>)) {
params[i] = param.getClass().getSimpleName();
} else {
params[i] = Objects.toString(param);
}
}
CacheSpec.interner.remove();
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Appends an array placing separators between each value, but
* not before the first or after the last.
* Appending a null array will have no effect.
* Each object is appended using {@link #append(Object)}.
*
* @param array the array to append
* @param separator the separator to use, null means no separator
* @return this, to enable chaining
*/
public StrBuilder appendWithSeparators(final Object[] array, final String separator) {
if (array != null && array.length > 0) {
final String sep = Objects.toString(separator, "");
append(array[0]);
for (int i = 1; i < array.length; i++) {
append(sep);
append(array[i]);
}
}
return this;
}
代码示例来源:origin: ben-manes/caffeine
/** Free memory by clearing unused resources after test execution. */
static void cleanUp(ITestResult testResult) {
Object[] params = testResult.getParameters();
for (int i = 0; i < params.length; i++) {
Object param = params[i];
if ((param instanceof SingleConsumerQueue<?>)) {
boolean linearizable =
(((SingleConsumerQueue<?>) param).factory.apply(null) instanceof LinearizableNode<?>);
params[i] = param.getClass().getSimpleName() + "_"
+ (linearizable ? "linearizable" : "optimistic");
} else {
params[i] = Objects.toString(param);
}
}
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public TopNResultBuilder addEntry(DimensionAndMetricValueExtractor dimensionAndMetricValueExtractor)
{
Object dimensionValueObj = dimensionAndMetricValueExtractor.getDimensionValue(dimSpec.getOutputName());
String dimensionValue = Objects.toString(dimensionValueObj, null);
if (shouldAdd(dimensionValue)) {
pQueue.add(
new DimValHolder.Builder().withDimValue(dimensionValue)
.withMetricValues(dimensionAndMetricValueExtractor.getBaseObject())
.build()
);
if (pQueue.size() > threshold) {
pQueue.poll();
}
}
return this;
}
代码示例来源:origin: apache/hbase
protected void dumpBackupDir() throws IOException {
// Dump Backup Dir
FileSystem fs = FileSystem.get(conf1);
RemoteIterator<LocatedFileStatus> it = fs.listFiles(new Path(BACKUP_ROOT_DIR), true);
while (it.hasNext()) {
LOG.debug(Objects.toString(it.next().getPath()));
}
}
}
代码示例来源:origin: apache/hbase
public FailedProcedure(long procId, String procName, User owner, NonceKey nonceKey,
IOException exception) {
this.procName = procName;
setProcId(procId);
setState(ProcedureState.ROLLEDBACK);
setOwner(owner);
setNonceKey(nonceKey);
long currentTime = EnvironmentEdgeManager.currentTime();
setSubmittedTime(currentTime);
setLastUpdate(currentTime);
setFailure(Objects.toString(exception.getMessage(), ""), exception);
}
内容来源于网络,如有侵权,请联系作者删除!