List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.kitodo.production.helper.tasks.CreateNewspaperProcessesTask.java
/** * The function addMetadatum() adds a metadata to the given level of the * logical document structure hierarchy. * * @param level// w w w . j a v a2 s . c o m * level of the logical document structure to create a child in * @param key * name of the metadata to create * @param value * value to set the metadata to * @param fail * if true, throws an error on fail, otherwise returns silently */ private void addMetadatum(LegacyDocStructHelperInterface level, String key, String value, boolean fail) { try { throw new UnsupportedOperationException("Dead code pending removal"); } catch (RuntimeException e) { if (fail) { throw new ProcessCreationException("Could not create metadatum " + key + " in " + (Objects.nonNull(level.getDocStructType()) ? "DocStrctType " + level.getDocStructType().getName() : "anonymous DocStrctType") + ": " + e.getClass().getSimpleName().replace("NullPointerException", "No metadata types are associated with that DocStructType."), e); } } }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
private List<Suit> getSuitsForRank(Rank rank) { List<Suit> suites = new ArrayList(); for (Entry<Suit, Rank[]> entry : hand.entrySet()) { if (Objects.nonNull(entry.getValue()[rank.value() - 2])) { suites.add(entry.getKey());/*from w ww . j a v a2 s. c om*/ } } return suites; }
From source file:org.egov.pgr.elasticsearch.service.ComplaintIndexService.java
public void updateComplaintIndex(final Complaint complaint) { // fetch the complaint from index and then update the new fields ComplaintIndex complaintIndex = complaintIndexRepository.findByCrnAndCityCode(complaint.getCrn(), getCityCode());/*from www . ja va 2s. co m*/ final String status = complaintIndex.getComplaintStatusName(); beanMapperConfiguration.map(complaint, complaintIndex); final City city = cityService.getCityByURL(ApplicationThreadLocals.getDomainName()); complaintIndex.setCityCode(city.getCode()); complaintIndex.setCityDistrictCode(city.getDistrictCode()); complaintIndex.setCityDistrictName(city.getDistrictName()); complaintIndex.setCityGrade(city.getGrade()); complaintIndex.setCityDomainUrl(city.getDomainURL()); complaintIndex.setCityName(city.getName()); complaintIndex.setCityRegionName(city.getRegionName()); final Position position = complaint.getAssignee(); final List<Assignment> assignments = assignmentService.getAssignmentsForPosition(position.getId(), new Date()); final User assignedUser = !assignments.isEmpty() ? assignments.get(0).getEmployee() : null; // If complaint is forwarded if (complaint.nextOwnerId() != null && !complaint.nextOwnerId().equals(0L)) { complaintIndex.setCurrentFunctionaryName(assignedUser != null ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName() : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName()); complaintIndex.setCurrentFunctionaryMobileNumber( Objects.nonNull(assignedUser) ? assignedUser.getMobileNumber() : EMPTY); complaintIndex.setCurrentFunctionaryAssigneddate(new Date()); complaintIndex.setCurrentFunctionarySLADays(getFunctionarySlaDays(complaint)); } complaintIndex = updateComplaintLevelIndexFields(complaintIndex); if (complaintIndex.getComplaintStatusName().equalsIgnoreCase(ComplaintStatus.COMPLETED.toString()) || complaintIndex.getComplaintStatusName().equalsIgnoreCase(ComplaintStatus.WITHDRAWN.toString()) || complaintIndex.getComplaintStatusName().equalsIgnoreCase(ComplaintStatus.REJECTED.toString())) { complaintIndex.setClosed(true); complaintIndex.setComplaintIsClosed("Y"); complaintIndex.setIfClosed(1); complaintIndex.setClosedByFunctionaryName(assignedUser != null ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName() : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName()); final long duration = Math.abs(complaintIndex.getCreatedDate().getTime() - new Date().getTime()) / (24 * 60 * 60 * 1000); complaintIndex.setComplaintDuration(duration); if (duration < 3) complaintIndex.setDurationRange("(<3 days)"); else if (duration < 7) complaintIndex.setDurationRange("(3-7 days)"); else if (duration < 15) complaintIndex.setDurationRange("(8-15 days)"); else if (duration < 30) complaintIndex.setDurationRange("(16-30 days)"); else complaintIndex.setDurationRange("(>30 days)"); } else { complaintIndex.setClosed(false); complaintIndex.setComplaintIsClosed("N"); complaintIndex.setIfClosed(0); complaintIndex.setComplaintDuration(0); complaintIndex.setDurationRange(""); } // update status related fields in index updateComplaintIndexStatusRelatedFields(complaintIndex); // If complaint is re-opened if (complaintIndex.getComplaintStatusName().equalsIgnoreCase(ComplaintStatus.REOPENED.toString()) && !status.contains(COMPLAINT_REOPENED)) { complaintIndex.setComplaintReOpenedDate(new Date()); complaintIndex.setClosed(false); complaintIndex.setComplaintIsClosed("N"); complaintIndex.setIfClosed(0); } // If complaint is rejected update the Reason For Rejection with comments if (complaintIndex.getComplaintStatusName().equalsIgnoreCase(ComplaintStatus.REJECTED.toString())) complaintIndex.setReasonForRejection(complaint.approverComment()); complaintIndexRepository.save(complaintIndex); }
From source file:de.hybris.platform.ordermanagementfacade.returns.impl.DefaultOmsReturnFacade.java
/** * Validates for null check and mandatory fields in returnRequestData * * @param returnRequestData/*from ww w . ja v a 2s . c om*/ * returnRequest to be validated */ protected void validateReturnRequestData(final ReturnRequestData returnRequestData) { Assert.notNull(returnRequestData, Localization.getLocalizedString("ordermanagementfacade.returns.validation.null.returnrequestdata")); Assert.notNull(returnRequestData.getOrder(), Localization.getLocalizedString("ordermanagementfacade.returns.validation.null.order")); Assert.isTrue( Objects.nonNull(returnRequestData.getEntries()) && CollectionUtils.isNotEmpty(returnRequestData.getEntries()), Localization.getLocalizedString("ordermanagementfacade.returns.validation.null.returnentries")); final Boolean refundDeliveryCostRequested = returnRequestData.getRefundDeliveryCost(); if (refundDeliveryCostRequested != null && refundDeliveryCostRequested) { Assert.isTrue( canRefundDeliveryCost(returnRequestData.getOrder().getCode(), returnRequestData.getRefundDeliveryCost()), String.format( Localization.getLocalizedString("ordermanagementfacade.returns.error.deliverycost"), returnRequestData.getOrder().getCode())); } returnRequestData.getEntries().forEach(entry -> validateReturnEntryData(entry)); }
From source file:org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationBase.java
private <T, S> List<Map<T, S>> mergeLists(List<Map<T, S>> target, List<Map<T, S>> source, Class<S> value) { List<Map<T, S>> retList = new ArrayList<>(); if (Objects.nonNull(target)) { retList.addAll(target);/* w w w . j a va2 s. c o m*/ } if (Objects.nonNull(source)) { for (Map<T, S> sourceMap : source) { for (Map.Entry<T, S> entry : sourceMap.entrySet()) { mergeEntryInList(entry.getKey(), entry.getValue(), retList); } } } return retList; }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
private Suit getSuitForRank(Rank rank) { Suit suit = null;/*from ww w . j a v a 2 s .com*/ for (Entry<Suit, Rank[]> entry : hand.entrySet()) { if (Objects.nonNull(entry.getValue()[rank.value() - 2])) { suit = entry.getKey(); break; } } return suit; }
From source file:org.kitodo.production.exporter.ExportXmlLog.java
/** * This method transforms the xml log using a xslt file and opens a new window * with the output file.//from w w w.jav a 2 s . com * * @param out * ServletOutputStream * @param doc * the xml document to transform * @param filename * the filename of the xslt */ private void xmlTransformation(OutputStream out, Document doc, String filename) throws XSLTransformException, IOException { Document docTrans; if (Objects.nonNull(filename) && filename.isEmpty()) { XSLTransformer transformer; transformer = new XSLTransformer(filename); docTrans = transformer.transform(doc); } else { docTrans = doc; } Format format = Format.getPrettyFormat(); format.setEncoding(StandardCharsets.UTF_8.name()); XMLOutputter xmlOut = new XMLOutputter(format); xmlOut.output(docTrans, out); }
From source file:org.kitodo.production.forms.dataeditor.StructurePanel.java
private TreeNode updateLogicalNodeSelectionRecursive(IncludedStructuralElement structure, TreeNode treeNode) { TreeNode matchingTreeNode = null; for (TreeNode currentTreeNode : treeNode.getChildren()) { if (treeNodeMatchesStructure(structure, currentTreeNode)) { currentTreeNode.setSelected(true); matchingTreeNode = currentTreeNode; } else {/* w w w . j a v a2s . c o m*/ matchingTreeNode = updateLogicalNodeSelectionRecursive(structure, currentTreeNode); } if (Objects.nonNull(matchingTreeNode)) { break; } } return matchingTreeNode; }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
private Entry<Suit, Rank[]> getFlushEntry() { for (Entry<Suit, Rank[]> entry : hand.entrySet()) { int count = 0; Rank[] ranks = entry.getValue(); for (Rank r : ranks) { if (Objects.nonNull(r)) { count++;//from w ww . j a va 2 s . co m } } if (count >= 5) { return entry; } } return null; }
From source file:org.goobi.production.cli.helper.CopyProcess.java
/** * Evaluate the token as field name./*ww w .j ava 2 s . c o m*/ * * @param token * as String * @param stringBuilder * as StringBuilder */ private void appendDataFromAdditionalFields(String token, StringBuilder stringBuilder) { for (AdditionalField additionalField : this.additionalFields) { /* * if it is the ATS or TSL field, then use the calculated atstsl if it does not * already exist */ String title = additionalField.getTitle(); String value = additionalField.getValue(); if (("ATS".equals(title) || "TSL".equals(title)) && additionalField.showDependingOnDoctype() && StringUtils.isEmpty(value)) { additionalField.setValue(""); value = additionalField.getValue(); } // add the content to the title if (title.equals(token) && additionalField.showDependingOnDoctype() && Objects.nonNull(value)) { stringBuilder.append(calcProcessTitleCheck(title, value)); } } }