List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.schemaspy.SchemaAnalyzer.java
private Connection getConnection(Config config) throws IOException { Properties properties = config.getDbProperties(); ConnectionURLBuilder urlBuilder = new ConnectionURLBuilder(config, properties); if (config.getDb() == null) config.setDb(urlBuilder.build()); String driverClass = properties.getProperty("driver"); String driverPath = properties.getProperty("driverPath"); if (Objects.isNull(driverPath)) driverPath = ""; if (Objects.nonNull(config.getDriverPath())) driverPath = config.getDriverPath(); DbDriverLoader driverLoader = new DbDriverLoader(); return driverLoader.getConnection(config, urlBuilder.build(), driverClass, driverPath); }
From source file:org.kitodo.production.forms.dataeditor.StructurePanel.java
private boolean treeNodeMatchesStructure(IncludedStructuralElement structure, TreeNode treeNode) { if (Objects.nonNull(treeNode) && treeNode.getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); if (structureTreeNode.getDataObject() instanceof IncludedStructuralElement) { return Objects.equals(structureTreeNode.getDataObject(), structure); }/*from ww w .j ava 2 s . c o m*/ } return false; }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
/** * A 5 high straight flush, with ace as the low card * * @param cards/* w w w. j a v a 2 s .c om*/ * @return */ private boolean isWheel(Card[] cards) { if (Objects.nonNull(cards) && cards.length == 5) { Arrays.sort(cards, this); int i, j; boolean isConsec = false; for (i = cards.length - 2, j = i - 1; j >= 0; i--, j--) { if (Math.abs(cards[j].getRank().value() - cards[i].getRank().value()) != 1) { isConsec = true; } else { break; } } return isConsec && cards[0].getRank() == Rank.TWO && cards[cards.length - 1].getRank() == Rank.ACE; } return false; }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java
private Map<Integer, double[]> getFourierMap() { // Fourier components of multiple scattering Map<Integer, double[]> fourierPoly = new HashMap<>(); double[] sunZenithAnglesRad = getSunZenithAnglesRad(); double[] viewZenithAnglesRad = getViewZenithAnglesRad(); double[] cosSZARads = getCosSZARads(); double[] cosOZARads = getCosOZARads(); double[] sinSZARads = getSinSZARads(); double[] sinOZARads = getSinOZARads(); double[] sinOZA2s = getSquarePower(sinOZARads); double[] sinSZA2s = getSquarePower(sinSZARads); if (Objects.nonNull(sunZenithAnglesRad) && Objects.nonNull(viewZenithAnglesRad)) { for (int index = 0; index < sunZenithAnglesRad.length; index++) { double cosSZARad = cosSZARads[index]; double cosOZARad = cosOZARads[index]; double sinSZARad = sinSZARads[index]; double sinOZARad = sinOZARads[index]; double sinSZA2 = sinSZA2s[index]; double sinOZA2 = sinOZA2s[index]; double[] fourierSeries = new double[3]; //Rayleigh Phase function, 3 Fourier terms fourierSeries[0] = (3.0 * 0.9587256 / 4.0 * (1 + (cosSZARad * cosSZARad) * (cosOZARad * cosOZARad) + (sinSZA2 * sinOZA2) / 2.0) + (1.0 - 0.9587256)); fourierSeries[1] = (-3.0 * 0.9587256 / 4.0 * cosSZARad * cosOZARad * sinSZARad * sinOZARad); fourierSeries[2] = (3.0 * 0.9587256 / 16.0 * sinSZA2 * sinOZA2); fourierPoly.put(index, fourierSeries); }//from www. ja va 2 s. com return fourierPoly; } throw new NullPointerException("The Fourier polynomial is empty."); }
From source file:org.kitodo.production.plugin.importer.massimport.PicaMassImport.java
private List<Record> getRecordsForXLSX(InputStream xls) throws IOException { List<Record> records = new ArrayList<>(); XSSFWorkbook wb = new XSSFWorkbook(xls); XSSFSheet sheet = wb.getSheetAt(0); // first sheet // loop over all rows for (int j = 0; j <= sheet.getLastRowNum(); j++) { // loop over all cells XSSFRow row = sheet.getRow(j);/*from w w w .j a va 2s. c om*/ if (Objects.nonNull(row)) { for (int i = 0; i < row.getLastCellNum(); i++) { XSSFCell cell = row.getCell(i); // changing all cell types to String cell.setCellType(HSSFCell.CELL_TYPE_STRING); Record record = changeCellTypeToString(cell, i, j); if (Objects.nonNull(record)) { records.add(record); } } } } return records; }
From source file:org.kitodo.export.ExportDms.java
/** * Download image.// w w w. j av a 2 s . co m * * @param process * object * @param userHome * File * @param atsPpnBand * String * @param ordnerEndung * String */ public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung) throws IOException { // determine the source folder URI tifOrdner = ServiceManager.getProcessService().getImagesTifDirectory(true, process.getId(), process.getTitle(), process.getProcessBaseUri()); // copy the source folder to the destination folder if (fileService.fileExist(tifOrdner) && !fileService.getSubUris(tifOrdner).isEmpty()) { URI zielTif = userHome.resolve(atsPpnBand + ordnerEndung + "/"); /* bei Agora-Import einfach den Ordner anlegen */ if (process.getProject().isUseDmsImport()) { if (!fileService.fileExist(zielTif)) { fileService.createDirectory(userHome, atsPpnBand + ordnerEndung); } } else { // if no async import, then create the folder with user // authorization again User user = ServiceManager.getUserService().getAuthenticatedUser(); try { fileService.createDirectoryForUser(zielTif, user.getLogin()); } catch (IOException e) { handleException(e, process.getTitle()); throw e; } catch (RuntimeException e) { handleException(e, process.getTitle()); } } if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setWorkDetail(null); } } }
From source file:org.kitodo.export.ExportDms.java
private void handleException(Exception e, String processTitle) { if (Objects.nonNull(exportDmsTask)) { exportDmsTask.setException(e);//from ww w . j a v a2s. co m logger.error("Could not create destination directory", e); } else { Helper.setErrorMessage(ERROR_EXPORT, new Object[] { processTitle }, logger, e); } }
From source file:org.kitodo.production.services.command.KitodoScriptService.java
private void exportDms(List<Process> processes, String exportImages) { boolean withoutImages = Objects.nonNull(exportImages) && exportImages.equalsIgnoreCase("false"); for (Process process : processes) { try {/* w ww . ja va 2 s. c o m*/ ExportDms dms = new ExportDms(!withoutImages); dms.startExport(process); } catch (IOException e) { logger.error(e.getMessage(), e); } } }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
@Override public int compare(Card o1, Card o2) { if (Objects.nonNull(o1) && Objects.nonNull(o2)) { return o1.compareTo(o2); } else if (Objects.isNull(o1)) { return 1; } else {//from w w w .jav a2s.c o m return -1; } }
From source file:org.kitodo.production.plugin.importer.massimport.PicaMassImport.java
private List<Record> getRecordsForXLS(InputStream xls) throws IOException { List<Record> records = new ArrayList<>(); HSSFWorkbook wb = new HSSFWorkbook(xls); HSSFSheet sheet = wb.getSheetAt(0); // first sheet // loop over all rows for (int j = 0; j <= sheet.getLastRowNum(); j++) { // loop over all cells HSSFRow row = sheet.getRow(j);//from ww w . ja v a2 s . co m if (Objects.nonNull(row)) { for (int i = 0; i < row.getLastCellNum(); i++) { HSSFCell cell = row.getCell(i); // changing all cell types to String if (Objects.nonNull(cell)) { cell.setCellType(HSSFCell.CELL_TYPE_STRING); Record record = changeCellTypeToString(cell, i, j); if (Objects.nonNull(record)) { records.add(record); } } } } } return records; }