List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:com.qpark.eip.core.model.analysis.AnalysisDao.java
/** * @see com.qpark.eip.core.model.analysis.report.DataProviderModelAnalysis#getComplexType(java.lang.String) *//* ww w . jav a 2s . c om*/ @Override @Transactional(value = EipModelAnalysisPersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED) public Optional<ComplexType> getComplexType(final String complexTypeId) { final Optional<ComplexType> value = this.getDataTypes(Arrays.asList(complexTypeId)).stream() .filter(dt -> Objects.nonNull(dt) && ComplexType.class.isInstance(dt)).map(dt -> (ComplexType) dt) .findFirst(); return value; }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java
public double[] getAltitudes() { if (Objects.isNull(altitudes)) { double[] longitudes = getLongitude(); double[] latitudes = getLatitudes(); if (Objects.nonNull(longitudes) && Objects.nonNull(latitudes)) { double[] elevation = new double[latitudes.length]; for (int i = 0; i < longitudes.length; i++) { try { elevation[i] = elevationModel.getElevation(new GeoPos(latitudes[i], longitudes[i])); } catch (Exception e) { e.printStackTrace(); }/*w w w. ja v a2s . c o m*/ } altitudes = elevation; } } return altitudes; }
From source file:com.design.perpetual.resttodo.app.entities.Todo.java
@Override public boolean merge(Todo t) { boolean merged = false; if (Objects.nonNull(t)) { Field[] thisFields = getFields(this); Field[] paramFields = getFields(t); for (Field f : thisFields) { f.setAccessible(true);//from w ww . ja v a 2s. c om Column col = f.getAnnotation(Column.class); if (Objects.nonNull(col)) { for (Field pf : paramFields) { pf.setAccessible(true); if (f.getName().equals(pf.getName())) { try { Object thisVal = f.get(this); Object parVal = pf.get(t); if (!Objects.equals(thisVal, parVal)) { f.set(this, parVal); if (!merged) { merged = !merged; } } } catch (IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(Todo.class.getName()).log(Level.SEVERE, null, ex); } } } } } } return merged; }
From source file:com.caricah.iotracah.datastore.ignitecache.internal.AbstractHandler.java
public Observable<T> getByKey(K key) { return Observable.create(observer -> { try {//from ww w . j av a 2s. c o m // do work on separate thread T actualResult = getDatastoreCache().get(key); if (Objects.nonNull(actualResult)) { observer.onNext(actualResult); observer.onCompleted(); } else { observer.onError(new DoesNotExistException( String.format("%s with key [%s] does not exist.", classType, key))); } } catch (Exception e) { observer.onError(e); } }); }
From source file:org.kitodo.production.services.file.FileService.java
/** * Creates a directory at a given URI with a given name. * * @param parentFolderUri//ww w . j a v a 2s.c o m * the uri, where the directory should be created * @param directoryName * the name of the directory. * @return the URI of the new directory or URI of parent directory if * directoryName is null or empty */ public URI createDirectory(URI parentFolderUri, String directoryName) throws IOException { if (Objects.nonNull(directoryName)) { return fileManagementModule.create(parentFolderUri, directoryName, false); } return URI.create(""); }
From source file:de.speexx.csv.table.app.Application.java
Optional<RowReader> executeQuery(final Configuration conf, final List<Table> tables) throws Exception { assert Objects.nonNull(conf) : "Configuration is null"; assert Objects.nonNull(tables) : "No tables. Is null"; // At this time only one table is supported. Might be improved later. if (!tables.isEmpty()) { final SelectQueryData queryData = conf.getQueryData().getQueryData(); final String select = queryData.getAdjustedQuery().getQuery(); final Table table = tables.get(0); final RowReader result = table.executeSql(select); return Optional.of(result); }//w w w. j ava 2 s . c o m return Optional.empty(); }
From source file:com.qpark.eip.core.spring.PayloadLogger.java
/** * {@link Message} to string./*ww w. j av a2 s . c om*/ * * @param message * the {@link Message}. * @return the {@link Message} as string. */ private String getMessage(final Message<?> message) { Object logMessage = this.expression.getValue(this.evaluationContext, message); if (JAXBElement.class.isInstance(logMessage)) { final JAXBElement<?> elem = (JAXBElement<?>) logMessage; try { if (Objects.nonNull(this.jaxb2Marshaller)) { final StringResult sw = new StringResult(); this.jaxb2Marshaller.marshal(logMessage, sw); logMessage = sw.toString(); } else { final Marshaller marshaller = this.getMarshaller(); if (Objects.nonNull(marshaller)) { final StringWriter sw = new StringWriter(); marshaller.marshal(logMessage, sw); logMessage = sw.toString(); } } } catch (final Exception e) { logMessage = elem.getValue(); } } else if (logMessage instanceof Throwable) { final StringWriter stringWriter = new StringWriter(); if (logMessage instanceof AggregateMessageDeliveryException) { stringWriter.append(((Throwable) logMessage).getMessage()); for (final Exception exception : (List<? extends Exception>) ((AggregateMessageDeliveryException) logMessage) .getAggregatedExceptions()) { exception.printStackTrace(new PrintWriter(stringWriter, true)); } } else { ((Throwable) logMessage).printStackTrace(new PrintWriter(stringWriter, true)); } logMessage = stringWriter.toString(); } final StringBuffer sb = new StringBuffer(1024); sb.append(MessageHeaders.ID).append("=").append(message.getHeaders().getId()); final Object correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId(); if (correlationId != null) { sb.append(", "); sb.append(IntegrationMessageHeaderAccessor.CORRELATION_ID).append("=").append(correlationId); } sb.append("\n"); sb.append(String.valueOf(logMessage)); return sb.toString(); }
From source file:com.amanmehara.programming.android.adapters.LanguageAdapter.java
private void setLanguageLogo(ViewHolder viewHolder, JSONArray programs, String languageName) { for (int i = 0; i < programs.length(); i++) { try {//w w w. j a va2s.c o m JSONObject jsonObject = programs.getJSONObject(i); if (jsonObject.getString("name").equals("icon.png") && jsonObject.getString("type").equals(FILE.getValue())) { String url = jsonObject.getString("url"); String response = sharedPreferences.getString(url, null); if (Objects.nonNull(response)) { getLogoResponseCallback(url, true, languageName, viewHolder).accept(response); } else { new GithubAPIClient(activity, getLogoResponseCallback(url, false, languageName, viewHolder)) .execute(withAccessToken(url)); } } } catch (JSONException e) { Log.e(TAG, e.getMessage()); viewHolder.languageImageView.setImageResource(R.drawable.ic_circle_logo); } } }
From source file:org.kitodo.production.forms.dataeditor.StructurePanel.java
/** * Updates the live structure of a structure tree node and returns it, to * provide for updating the parent. If the tree node contains children which * arent structures, {@code null} is returned to skip them on the level * above./* ww w .ja v a 2 s .co m*/ */ private static IncludedStructuralElement preserveLogicalRecursive(TreeNode treeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); if (Objects.isNull(structureTreeNode) || !(structureTreeNode.getDataObject() instanceof IncludedStructuralElement)) { return null; } IncludedStructuralElement structure = (IncludedStructuralElement) structureTreeNode.getDataObject(); List<IncludedStructuralElement> childrenLive = structure.getChildren(); childrenLive.clear(); for (TreeNode child : treeNode.getChildren()) { IncludedStructuralElement maybeChildStructure = preserveLogicalRecursive(child); if (Objects.nonNull(maybeChildStructure)) { childrenLive.add(maybeChildStructure); } } return structure; }
From source file:io.redlink.solrlib.embedded.EmbeddedCoreContainer.java
@Override public final void shutdown() throws IOException { Preconditions.checkState(Objects.nonNull(this.coreContainer), "Not initialized!"); try {// w ww .j a v a 2s . c o m final CoreContainer cc = this.coreContainer; this.coreContainer = null; cc.shutdown(); } catch (final Exception t) { log.error("Unexpected Error during CoreContainer.shutdown(): {}", t.getMessage()); throw t; } if (deleteOnShutdown) { log.debug("Cleaning up solr-home {}", solrHome); PathUtils.deleteRecursive(solrHome); } }