List of usage examples for java.util Objects toString
public static String toString(Object o, String nullDefault)
From source file:org.jnosql.diana.orientdb.document.OrientDBDocumentCollectionManager.java
@Override public DocumentEntity insert(DocumentEntity entity) throws NullPointerException { Objects.toString(entity, "Entity is required"); try (ODatabaseDocumentTx tx = pool.acquire()) { ODocument document = new ODocument(entity.getName()); Map<String, Object> entityValues = toMap(entity); entityValues.keySet().stream().forEach(k -> document.field(k, entityValues.get(k))); ODocument save = null;/*ww w . jav a2 s . c om*/ try { save = tx.save(document); } catch (ONeedRetryException e) { save = tx.reload(document); } if (Objects.nonNull(save)) { ORecordId ridField = save.field("@rid"); if (Objects.nonNull(ridField)) { entity.add(Document.of(RID_FIELD, ridField.toString())); } } return entity; } }
From source file:com.norconex.commons.wicket.markup.html.chart.jqplot.options.PlotToStringBuilder.java
public PlotToStringBuilder rawArray(String name, Object[] array) { if (array == null) { return this; }/* w w w . j ava 2 s .co m*/ StringBuilder b = new StringBuilder("["); for (Object object : array) { if (b.length() > 2) { b.append(", "); } b.append(Objects.toString(object, "")); } b.append("]"); list.add(name + ":" + b.toString()); return this; }
From source file:therian.operator.FromSourceToTarget.java
@Override public String toString() { return String.format("%s from %s to %s", getClass().getSimpleName(), Objects.toString(sourceBound, UNKNOWN), Objects.toString(targetBound, UNKNOWN)); }
From source file:de.micromata.genome.logging.spi.ifiles.IndexFileLoggingImpl.java
@Override public String formatLogId(Object logId) { return Objects.toString(logId, StringUtils.EMPTY); }
From source file:io.twipple.springframework.data.clusterpoint.mapping.BasicClusterpointPersistentEntity.java
@Override @NotNull//from w w w.j a v a 2 s. c o m public Object getTypeAlias() { if (qualifiedName == null) { String namespaceUri = buildXmlNamespace(); String localName = Objects.toString(super.getTypeAlias(), null); if (localName == null) { localName = buildXmlLocalName(); } String prefix = buildXmlPrefix(); qualifiedName = new QName(namespaceUri, localName, prefix); } return qualifiedName; }
From source file:org.xwiki.refactoring.internal.batch.DefaultBatchOperationExecutor.java
@Override public String getCurrentBatchId() { Object existingBatchIdObject = execution.getContext().getProperty(CONTEXT_PROPERTY); String batchId = Objects.toString(existingBatchIdObject, null); return batchId; }
From source file:org.dspace.app.rest.security.EPersonRestAuthenticationProvider.java
private Authentication authenticateNewLogin(Authentication authentication) { Context newContext = null;/*from w w w . ja va2 s . co m*/ Authentication output = null; if (authentication != null) { try { newContext = new Context(); String name = authentication.getName(); String password = Objects.toString(authentication.getCredentials(), null); int implicitStatus = authenticationService.authenticateImplicit(newContext, null, null, null, request); if (implicitStatus == AuthenticationMethod.SUCCESS) { log.info(LogManager.getHeader(newContext, "login", "type=implicit")); output = createAuthentication(password, newContext); } else { int authenticateResult = authenticationService.authenticate(newContext, name, password, null, request); if (AuthenticationMethod.SUCCESS == authenticateResult) { log.info(LogManager.getHeader(newContext, "login", "type=explicit")); output = createAuthentication(password, newContext); } else { log.info(LogManager.getHeader(newContext, "failed_login", "email=" + name + ", result=" + authenticateResult)); throw new BadCredentialsException("Login failed"); } } } finally { if (newContext != null && newContext.isValid()) { try { newContext.complete(); } catch (SQLException e) { log.error(e.getMessage() + " occurred while trying to close", e); } } } } return output; }
From source file:de.micromata.genome.logging.spi.FileLogConfigurationDAOImpl.java
@Override protected void buildPattern() { Properties p = loadProperties(); if (p == null) { return;/*from www .ja v a 2 s .c o m*/ } List<Pair<String, Integer>> npattern = new ArrayList<>(); for (Map.Entry<Object, Object> me : p.entrySet()) { String pattern = Objects.toString(me.getKey(), StringUtils.EMPTY); String v = Objects.toString(me.getValue(), StringUtils.EMPTY); LogLevel ll = LogLevel.valueOf(v); int ilev = ll.getLevel(); if (pattern.equals(THRESHOLD_NAME) == true) { setMaxThreshold(ilev); } else { npattern.add(new Pair<String, Integer>(pattern, ilev)); } } Collections.sort(npattern, new Comparator<Pair<String, Integer>>() { /** * @param o1 the object1 * @param o2 the object2 * @return the compare result */ @Override public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return o2.getFirst().length() - o1.getFirst().length(); } }); List<Pair<Matcher<String>, Integer>> ncpattern = new ArrayList<Pair<Matcher<String>, Integer>>(); for (Pair<String, Integer> pp : npattern) { ncpattern.add(new Pair<Matcher<String>, Integer>(matcherFactory.createMatcher(pp.getFirst()), pp.getSecond())); } synchronized (this) { pattern = ncpattern; } }
From source file:com.norconex.commons.lang.xml.EnhancedXMLStreamWriter.java
private void writeAttributeObject(String localName, Object value) throws XMLStreamException { String strValue = Objects.toString(value, null); if (StringUtils.isNotBlank(strValue)) { writeAttribute(localName, strValue); } else if (writeBlanks) { writeAttribute(localName, StringUtils.EMPTY); }/*w ww. j a va2 s . co m*/ }
From source file:com.github.anba.test262.util.Test262Info.java
/** * Parses the test-info from the input file and returns a * {@link Test262Info} object//from w ww . j ava 2 s . c om */ public static Test262Info from(Path path, String defaultCharset) throws IOException { Test262Info info = new Test262Info(); InputStream stream = Files.newInputStream(path); Reader reader = newReader(stream, defaultCharset); try ($LineIterator lines = new $LineIterator(reader)) { boolean preamble = true; for (String line : iterable(lines)) { if (preamble) { if (start.matcher(line).matches()) { preamble = false; } } else if (end.matcher(line).matches()) { break; } else { Matcher m = tags.matcher(line); if (m.matches()) { String type = m.group(1); String val = m.group(2); switch (type) { case "description": info.description = requireNonNull(val, "description must not be null"); break; case "noStrict": requireNull(val); info.noStrict = true; break; case "onlyStrict": requireNull(val); info.onlyStrict = true; break; case "negative": info.negative = true; info.errorType = Objects.toString(val, info.errorType); break; case "hostObject": case "reviewers": case "generator": case "verbatim": case "noHelpers": case "bestPractice": case "implDependent": // ignore for now break; // legacy case "strict_mode_negative": info.negative = true; info.onlyStrict = true; info.errorType = Objects.toString(val, info.errorType); break; case "strict_only": requireNull(val); info.onlyStrict = true; break; case "errortype": info.errorType = requireNonNull(val, "error-type must not be null"); break; case "assertion": case "section": case "path": case "comment": case "name": // ignore for now break; default: // error System.err.printf("unhandled type '%s'\n", type); } } } } } return info; }