Java Code Examples for java.util.Objects#toString()
The following examples show how to use
java.util.Objects#toString() .
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: ObjectSpy.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
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()); } }
Example 2
Source File: AbstractExpressionGenerator.java From sarl with Apache License 2.0 | 6 votes |
/** 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; }
Example 3
Source File: StartStreaming.java From ditto with Eclipse Public License 2.0 | 5 votes |
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; }
Example 4
Source File: SitemapSubscriptionService.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
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); } } }
Example 5
Source File: N4ExecutableExtensionFactory.java From n4js with Eclipse Public License 1.0 | 5 votes |
@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; }
Example 6
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
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); }
Example 7
Source File: Asserts.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 8
Source File: BasicTransferable.java From java-swing-tips with MIT License | 5 votes |
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); }
Example 9
Source File: Repl.java From es6draft with MIT License | 5 votes |
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; }
Example 10
Source File: JobOperationServiceImpl.java From sdmq with Apache License 2.0 | 5 votes |
@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; }
Example 11
Source File: LogUtil.java From Lottor with MIT License | 5 votes |
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); } }
Example 12
Source File: Asserts.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 13
Source File: MybatisRuntimeContext.java From jeesuite-libs with Apache License 2.0 | 4 votes |
private static String getStringValue(String key){ if(context.get() == null)return null; return Objects.toString(context.get().get(key), null); }
Example 14
Source File: Mapping.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public void setProcess(String process) { this.process = Objects.toString(process, ""); }
Example 15
Source File: ActionControl.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private void dd(CommandLine cmd) throws Exception { String path = Objects.toString(cmd.getOptionValue(CMD_DD), ""); DumpData dumpData = new DumpData(); dumpData.execute(path); }
Example 16
Source File: OutParameter.java From sarl with Apache License 2.0 | 4 votes |
@Override public String toString() { return Objects.toString(this.value); }
Example 17
Source File: AttributeDifference.java From recheck with GNU Affero General Public License v3.0 | 4 votes |
public String getExpectedToString() { return Objects.toString( expected ); }
Example 18
Source File: IdLiteral.java From Mycat2 with GNU General Public License v3.0 | 4 votes |
@Override public String toString() { return Objects.toString(id); }
Example 19
Source File: MapStageFactoryTest.java From smallrye-reactive-streams-operators with Apache License 2.0 | 4 votes |
private String asString(int i) { return Objects.toString(i); }
Example 20
Source File: Asserts.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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); } }