下面列出了java.util.Objects#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void saveObjectToPage(WebORPage page, RecordObject rObject) {
WebORObject dupObj = findDuplicate(page);
if (dupObj == null) {
String objName = Objects.toString(rObject.getObjectname(), "Object");
int i = 1;
while (page.getObjectGroupByName(objName) != null) {
objName = rObject.getObjectname() + i++;
}
WebORObject newObj = page.addObject(objName);
dummyObject.clone(newObj);
setStatus("Object Added : " + objName);
((DefaultTreeModel) objectTree.getModel()).nodesWereInserted(page, new int[]{page.getChildCount() - 1});
objectTree.scrollPathToVisible(newObj.getTreePath());
} else {
setStatus("Object Already Present - Page : " + page.getName() + " - Object : " + dupObj.getName());
}
}
/** Get the string representation of an operator.
*
* @param call the call to the operator feature.
* @return the string representation of the operator or {@code null} if not a valid operator.
*/
protected String getOperatorSymbol(XAbstractFeatureCall call) {
if (call != null) {
final Resource res = call.eResource();
if (res instanceof StorageAwareResource) {
final boolean isLoadedFromStorage = ((StorageAwareResource) res).isLoadedFromStorage();
if (isLoadedFromStorage) {
final QualifiedName operator = getOperatorMapping().getOperator(
QualifiedName.create(call.getFeature().getSimpleName()));
return Objects.toString(operator);
}
}
return call.getConcreteSyntaxFeatureName();
}
return null;
}
private StartStreaming(final StartStreamingBuilder builder) {
streamingType = builder.streamingType;
connectionCorrelationId = builder.connectionCorrelationId;
authorizationContext = builder.authorizationContext;
@Nullable final Collection<String> namespacesFromBuilder = builder.namespaces;
namespaces = null != namespacesFromBuilder ? List.copyOf(namespacesFromBuilder) : Collections.emptyList();
filter = Objects.toString(builder.filter, null);
extraFields = builder.extraFields;
}
/**
* Asserts that {@code lhs} is the same as {@code rhs}.
*
* @param lhs The left hand side of the comparison.
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption; {@code null} for a default message.
* @throws RuntimeException if the assertion is not true.
*/
public static void assertSame(Object lhs, Object rhs, String msg) {
if (lhs != rhs) {
msg = Objects.toString(msg, "assertSame")
+ ": expected " + Objects.toString(lhs)
+ " to equal " + Objects.toString(rhs);
fail(msg);
}
}
public static void error(Logger logger, String format, Supplier<Object>... supplier) {
if (logger.isErrorEnabled()) {
String[] o = new String[supplier.length];
for (int i = 0; i < supplier.length; i++) {
o[i] = Objects.toString(supplier[i].get());
}
logger.info(format, o);
}
}
@Override
public String getBucketTop1Job(String bucketName) {
double to = Long.valueOf(System.currentTimeMillis() + BucketTask.TIME_OUT).doubleValue();
Set<String> sets = redisSupport.zrangeByScore(bucketName, 0, to, 0, 1);
if (sets != null && sets.size() > 0) {
String jobMsgId = Objects.toString(sets.toArray()[0]);
return jobMsgId;
}
return null;
}
private boolean printScriptFrames(ResourceBundle rb, PrintWriter pw, ExecutionContext cx, Throwable e, int level) {
final String indent = Strings.repeat('\t', level);
final int maxDepth = options.stacktraceDepth;
MessageFormat stackFrameFormat = messageFormat(rb, "stackframe");
int depth = 0;
StackTraceElement[] stackTrace = StackTraces.scriptStackTrace(e);
for (; depth < Math.min(stackTrace.length, maxDepth); ++depth) {
StackTraceElement element = stackTrace[depth];
String methodName = element.getMethodName();
String fileName = element.getFileName();
int lineNumber = element.getLineNumber();
pw.println(indent + formatMessage(stackFrameFormat, methodName, fileName, lineNumber));
}
if (depth < stackTrace.length) {
int skipped = stackTrace.length - depth;
pw.println(indent + formatMessage(rb, "frames_omitted", skipped));
}
boolean hasStacktrace = depth > 0;
if (e.getSuppressed().length > 0 && level == 1) {
Throwable suppressed = e.getSuppressed()[0];
String message;
if (suppressed instanceof ScriptException) {
message = ((ScriptException) suppressed).getMessage(cx);
} else {
message = Objects.toString(suppressed.getMessage(), suppressed.getClass().getSimpleName());
}
pw.println(indent + formatMessage(rb, "suppressed_exception", message));
hasStacktrace |= printScriptFrames(rb, pw, cx, suppressed, level + 1);
}
return hasStacktrace;
}
protected Object getHtmlTransferData(DataFlavor flavor) throws IOException, UnsupportedFlavorException {
// String data = getHtmlData();
// data = Objects.nonNull(data) ? data : "";
String data = Objects.toString(getHtmlData(), "");
if (String.class.equals(flavor.getRepresentationClass())) {
return data;
} else if (Reader.class.equals(flavor.getRepresentationClass())) {
return new StringReader(data);
} else if (InputStream.class.equals(flavor.getRepresentationClass())) {
// return new StringBufferInputStream(data);
return createInputStream(flavor, data);
}
throw new UnsupportedFlavorException(flavor);
}
/**
* Asserts that {@code lhs} is the same as {@code rhs}.
*
* @param lhs The left hand side of the comparison.
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption; {@code null} for a default message.
* @throws RuntimeException if the assertion is not true.
*/
public static void assertSame(Object lhs, Object rhs, String msg) {
if (lhs != rhs) {
msg = Objects.toString(msg, "assertSame")
+ ": expected " + Objects.toString(lhs)
+ " to equal " + Objects.toString(rhs);
throw new RuntimeException(msg);
}
}
private static String getInfo(JTable table) {
TableModel model = table.getModel();
int index = table.convertRowIndexToModel(table.getSelectedRow());
String str = Objects.toString(model.getValueAt(index, 0));
Integer idx = (Integer) model.getValueAt(index, 1);
Boolean flg = (Boolean) model.getValueAt(index, 2);
return String.format("%s, %d, %s", str, idx, flg);
}
@Override
public final void setInitializationData(final IConfigurationElement config, final String propertyName,
final Object data) throws CoreException {
if (data instanceof String) {
clazzName = (String) data;
} else if (data instanceof Map) {
clazzName = Objects.toString(((Map<?, ?>) data).get(GUICE_KEY));
}
if (clazzName == null) {
throw new IllegalArgumentException("Couldn't handle passed data : " + data);
}
this.config = config;
}
private void applyConfig(Map<String, Object> config) {
if (config == null) {
return;
}
final String max = Objects.toString(config.get("maxSubscriptions"), null);
if (max != null) {
try {
maxSubscriptions = Integer.parseInt(max);
} catch (NumberFormatException e) {
logger.debug("Setting 'maxSubscriptions' must be a number; value '{}' ignored.", max);
}
}
}
@Override
public String toString() {
return Objects.toString(this.value);
}
private void dd(CommandLine cmd) throws Exception {
String path = Objects.toString(cmd.getOptionValue(CMD_DD), "");
DumpData dumpData = new DumpData();
dumpData.execute(path);
}
private static String getStringValue(String key){
if(context.get() == null)return null;
return Objects.toString(context.get().get(key), null);
}
public void setProcess(String process) {
this.process = Objects.toString(process, "");
}
public String getExpectedToString() {
return Objects.toString( expected );
}
@Override
public String toString() {
return Objects.toString(id);
}
private String asString(int i) {
return Objects.toString(i);
}
/**
* Asserts that {@code lhs} is greater than {@code rhs}.
*
* @param <T> a type
* @param lhs The left hand side of the comparison.
* @param rhs The right hand side of the comparison.
* @param msg A description of the assumption; {@code null} for a default message.
* @throws RuntimeException if the assertion is not true.
*/
public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
if (!(compare(lhs, rhs, msg) > 0)) {
msg = Objects.toString(msg, "assertGreaterThan")
+ ": expected " + Objects.toString(lhs)
+ " > " + Objects.toString(rhs);
fail(msg);
}
}