List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:com.mac.holdempoker.app.impl.SimpleRound.java
@Override public void removeObserver(RoundObserver ro) { if (Objects.nonNull(ro)) { observers.remove(ro); } }
From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java
public HandRank getHand() throws InvalidHandException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (hasValidHand()) { Method[] methods = this.getClass().getDeclaredMethods(); Arrays.sort(methods, new MethodNameComparator()); for (Method method : methods) { method.setAccessible(true);//from w w w .j a va 2 s .c om String methodName = method.getName(); // System.out.println(methodName); Matcher m = METHOD_PATTERN.matcher(methodName); if (m.matches()) { Object[] args = null; Object obj = method.invoke(this, args); if (Objects.nonNull(obj)) { HandRank hr = (HandRank) obj; if (Objects.nonNull(hr)) { method.setAccessible(false); return hr; } } } method.setAccessible(false); } } throw new InvalidHandException(); }
From source file:org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationBase.java
static Optional<ResourceFileDataAndIDs> getFileDataContainingResource(List<FileData> filesToSearch, String resourceId, TranslationContext context, FileData.Type... types) { if (CollectionUtils.isEmpty(filesToSearch)) { return Optional.empty(); }/*w w w . j av a2 s. c o m*/ List<FileData> fileDatas = Objects.isNull(types) ? filesToSearch : HeatToToscaUtil.getFilteredListOfFileDataByTypes(filesToSearch, types); for (FileData data : fileDatas) { HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil().yamlToObject( context.getFiles().getFileContent(data.getFile()), HeatOrchestrationTemplate.class); Map<String, Output> outputs = heatOrchestrationTemplate.getOutputs(); if (Objects.isNull(outputs)) { continue; } Output output = outputs.get(resourceId); if (Objects.nonNull(output)) { Optional<AttachedResourceId> attachedOutputId = HeatToToscaUtil.extractAttachedResourceId( data.getFile(), heatOrchestrationTemplate, context, output.getValue()); if (attachedOutputId.isPresent()) { AttachedResourceId attachedResourceId = attachedOutputId.get(); if (!attachedResourceId.isGetResource()) { logger.warn("output: '" + resourceId + "' in file '" + data.getFile() + "' is not defined as get_resource and therefor not supported."); continue; } ResourceFileDataAndIDs fileDataAndIDs = new ResourceFileDataAndIDs( (String) attachedResourceId.getEntityId(), (String) attachedResourceId.getTranslatedId(), data); return Optional.of(fileDataAndIDs); } } } return Optional.empty(); }
From source file:com.mac.holdempoker.app.impl.SimpleRound.java
@Override public void notifyObserver() { observers.stream().filter(o -> Objects.nonNull(o)).forEach(o -> { o.winningPlayers(players.toArray(new Player[players.size()])); });/*from w ww.ja va2s. c om*/ }
From source file:org.kitodo.api.dataformat.MediaUnit.java
@Override public String toString() { String fileName = "No file ("; if (!mediaFiles.isEmpty()) { URI uri = mediaFiles.entrySet().iterator().next().getValue(); fileName = FilenameUtils.getBaseName(uri.getPath()).concat(" ("); }/*w ww . jav a 2s . c om*/ if (Objects.nonNull(type)) { fileName = type + ' ' + fileName; } return mediaFiles.keySet().stream().map(MediaVariant::getUse) .collect(Collectors.joining(", ", fileName, ")")); }
From source file:org.apache.streams.riak.binary.RiakBinaryPersistReader.java
@Override public boolean isRunning() { return Objects.nonNull(client); }
From source file:it.greenvulcano.gvesb.virtual.rest.RestCallOperation.java
@Override public void init(Node node) throws InitializationException { logger.debug("Init start"); try {//from w w w.java 2s. c om name = XMLConfig.get(node, "@name"); String host = XMLConfig.get(node.getParentNode(), "@endpoint"); String uri = XMLConfig.get(node, "@request-uri"); method = XMLConfig.get(node, "@method"); url = host.concat(uri); connectionTimeout = XMLConfig.getInteger(node, "@conn-timeout", 3000); readTimeout = XMLConfig.getInteger(node, "@so-timeout", 6000); Node trustStore = XMLConfig.getNode(node.getParentNode(), "./truststore"); if (Objects.nonNull(trustStore)) { truststorePath = XMLConfig.get(trustStore, "@path"); truststorePassword = XMLConfig.getDecrypted(trustStore, "@password", null); truststoreAlgorithm = XMLConfig.get(trustStore, "@algorithm", null); } Node defaults = XMLConfig.getNode(node.getParentNode(), "./rest-call-defaults"); if (Objects.nonNull(defaults)) { readRestCallConfiguration(defaults); } readRestCallConfiguration(node); logger.debug("init - loaded parameters: url= " + url + " - method= " + method); logger.debug("Init stop"); } catch (Exception exc) { throw new InitializationException("GV_INIT_SERVICE_ERROR", new String[][] { { "message", exc.getMessage() } }, exc); } }
From source file:com.fantasy.stataggregator.workers.GameDataRetrieverTask.java
/** * Retrieves a JSON String representing a single NFL game played, on a given * day. Then save this data to the database, uniquely<br> * identified by the schedule. each schedule occurs on a given date<br> * in the format yyyyMMdd\d{2}, where \d{2} is a two digit number<br> * identifying 1 of n games played that day (range 00 - 15 or * fewer).<br><br>// ww w .j av a2 s.c o m * * run retrieves one game at a time, it is up the the controlling class, to * recursively call this method. * * @throws java.text.ParseException * @throws java.lang.InterruptedException */ @Override public void run() throws ParseException, InterruptedException { if (Objects.nonNull(year) && Objects.nonNull(schedules)) { while (!schedules.isEmpty()) { //get the earliest scheduled game GameSchedule sched = schedules.remove(FIRST_INDEX); //if this NflSchedule is in the past, proceed if (Objects.nonNull(sched) && hasBeenPlayed(sched)) { Response response = requestData(sched); //if request was successful, proceed with saving data. if (response.getStatus() == Response.Status.OK.getStatusCode()) { String nflData = response.readEntity(String.class); persistGameData(sched.getGameid(), nflData); System.out.println(count); } count++; } else if (Objects.nonNull(sched) && !hasBeenPlayed(sched)) { isTaskComplete = true; break; } Thread.sleep(2000L); } if (schedules.isEmpty()) { isTaskComplete = true; } } }
From source file:com.mac.halendpoint.endpoints.ProtocolRouter.java
@ProtocolMapping(routeTo = "command", respondTo = "status", numParams = 2) private Status command(String deviceName, String command) throws Exception { Status stat = Status.FAILED;//from ww w. ja v a 2 s . c om if (Objects.nonNull(deviceName) && Objects.nonNull(command)) { String uri = formUri(BASE_RESOURCE_PATH, deviceName, command); RestTemplate template = new RestTemplate(); stat = template.getForObject(uri, Status.class); } return stat; }
From source file:org.kitodo.production.forms.WorkflowForm.java
/** * Read XML for file chosen out of the select list. *//*from w w w.j a va2 s .co m*/ public void readXMLDiagram() { URI xmlDiagramURI = new File( ConfigCore.getKitodoDiagramDirectory() + encodeXMLDiagramName(this.workflow.getTitle())).toURI(); try (InputStream inputStream = fileService.read(xmlDiagramURI); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { StringBuilder sb = new StringBuilder(); String line = bufferedReader.readLine(); while (Objects.nonNull(line)) { sb.append(line).append("\n"); line = bufferedReader.readLine(); } xmlDiagram = sb.toString(); } catch (IOException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } }