List of usage examples for java.util Objects nonNull
public static boolean nonNull(Object obj)
From source file:org.eclipse.winery.repository.rest.resources.API.AccountabilityResource.java
@GET @Path("authenticate") @Produces(MediaType.APPLICATION_JSON)//from w w w. j a va 2 s . c om public List<AuthorizationNode> getAuthentication(@QueryParam("participantAddress") String participantAddress) { AuthorizationInfo authorizationInfo; try { authorizationInfo = getAccountabilityManager().getAuthorization(provenanceId) .exceptionally(error -> null).get(); } catch (InterruptedException | ExecutionException | AccountabilityException e) { LOGGER.error("Cannot authenticate participant {}. Reason: {}", participantAddress, e.getMessage()); throw createException(e); } if (Objects.nonNull(authorizationInfo)) { return authorizationInfo.getAuthorizationLineage(participantAddress).orElseGet(ArrayList::new); } return new ArrayList<>(); }
From source file:com.mac.halendpoint.endpoints.ProtocolRouter.java
@ProtocolMapping(routeTo = "listen", respondTo = "socket", numParams = 3) private String listen(String protocol, String host, String port) throws Exception { if (Objects.nonNull(protocol) && Objects.nonNull(host) && Objects.nonNull(port)) { String uri = formUri(BASE_RESOURCE_PATH, "listener", protocol, host, port); System.out.println("URI: " + uri); RestTemplate template = new RestTemplate(); return template.getForObject(uri, String.class); }//from w w w. j a v a 2s.c o m return Status.NOT_MODIFIED.name(); }
From source file:org.kitodo.data.elasticsearch.search.SearchRestClient.java
/** * Get document by query with possible sort of results. * * @param query//from ww w. ja v a 2 s.co m * to find a document * @param sort * as String with sort conditions * @param offset * as Integer * @param size * as Integer * @return http entity as String */ SearchHits getDocument(QueryBuilder query, SortBuilder sort, Integer offset, Integer size) throws CustomResponseException, DataException { SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); sourceBuilder.query(query); if (Objects.nonNull(sort)) { sourceBuilder.sort(sort); } if (Objects.nonNull(offset)) { sourceBuilder.from(offset); } if (Objects.nonNull(size)) { sourceBuilder.size(size); } else { sourceBuilder.size(1000); } SearchRequest searchRequest = new SearchRequest(this.index); searchRequest.types(this.type); searchRequest.source(sourceBuilder); try { SearchResponse response = highLevelClient.search(searchRequest); return response.getHits(); } catch (ResponseException e) { handleResponseException(e); return SearchHits.empty(); } catch (IOException e) { throw new DataException(e); } }
From source file:de.speexx.jira.jan.command.transition.IssueTransitionFetcher.java
LocalDateTime fetchCreationDateTime(final Issue issue) { assert Objects.nonNull(issue); return createLocalDateTime(issue.getCreationDate()); }
From source file:org.opendaylight.sxp.csit.libraries.DeviceTestLibrary.java
/** * @param mode Local Peer mode that will be checked * @param ip Ip-address of remote peer * @param port Port of remote peer/*from w ww . ja v a2 s . c o m*/ * @param nodeId NodeId of local SXP device * @return If specified peer si connected */ @RobotKeyword("Is Peer Connected") @ArgumentNames({ "mode", "ip", "port", "node_id" }) public synchronized boolean isPeerConnected(String mode, String ip, String port, String nodeId) { return LibraryServer.getNode(Objects.requireNonNull(nodeId)).getAllOnConnections().stream() .anyMatch(c -> Objects.nonNull(c) && c.getMode().equals(getMode(mode)) && c.getDestination().getPort() == Integer.parseInt(port) && Objects.equals(c.getDestination().getAddress().getHostAddress(), ip)); }
From source file:org.goobi.production.plugin.PluginLoader.java
/** * The function getPlugins() loads all plug-ins implementing the given * UnspecificPlugin class type and returns a Collection of redirection * classes, each to handle one plug-in implementation object. * * @param clazz//from w w w . j a va 2 s . co m * UnspecificPlugin class type of the plug-ins to load * @return a Collection of plug-in redirection classes */ @SuppressWarnings("unchecked") public static <T extends UnspecificPlugin> Collection<T> getPlugins(Class<T> clazz) { ArrayList<T> result = new ArrayList<>(); PluginType type = UnspecificPlugin.typeOf(clazz); if (Objects.nonNull(type)) { PluginManagerUtil pluginLoader = getPluginLoader(type); Collection<Plugin> plugins = pluginLoader.getPlugins(Plugin.class); // Never API version supports no-arg getPlugins() TODO: update API result = new ArrayList<>(plugins.size() - INTERNAL_CLASSES_COUNT); for (Plugin implementation : plugins) { if (implementation.getClass().getName().startsWith(INTERNAL_CLASSES_PREFIX)) { continue; // Skip plugin API internal classes } try { T plugin = (T) UnspecificPlugin.create(type, implementation); plugin.configure(getPluginConfiguration()); result.add(plugin); } catch (NoSuchMethodException | SecurityException e) { logger.warn("Bad implementation of {} plugin {}. Exception: {}", type.getName(), implementation.getClass().getName(), e); } } } return result; }
From source file:it.greenvulcano.gvesb.virtual.rest.RestCallOperation.java
private void readRestCallConfiguration(Node node) throws XMLConfigException { if (XMLConfig.exists(node, "./headers")) { fillMap(XMLConfig.getNodeList(node, "./headers/header"), headers); }/* w w w .j a va2 s. com*/ if (XMLConfig.exists(node, "./parameters")) { fillMap(XMLConfig.getNodeList(node, "./parameters/param"), params); } Node bodyNode = XMLConfig.getNode(node, "./body"); if (Objects.nonNull(bodyNode)) { sendGVBufferObject = Boolean.valueOf(XMLConfig.get(bodyNode, "@gvbuffer-object", "false")); body = bodyNode.getTextContent(); } else { body = null; } }
From source file:de.speexx.jira.jan.command.transition.IssueTransitionFetcher.java
String fetchPriority(final Issue issue) { assert Objects.nonNull(issue); return issue.getPriority().getName(); }
From source file:org.kitodo.production.services.command.KitodoScriptService.java
private boolean executeScript(List<Process> processes) throws DataException { // call the correct method via the parameter switch (this.parameters.get("action")) { case "importFromFileSystem": importFromFileSystem(processes); break;//from w w w. j a v a 2 s.c om case "addRole": addRole(processes); break; case "setTaskProperty": setTaskProperty(processes); break; case "setStepStatus": setTaskStatus(processes); break; case "addShellScriptToStep": addShellScriptToStep(processes); break; case "updateContentFiles": updateContentFiles(processes); break; case "deleteTiffHeaderFile": deleteTiffHeaderFile(processes); break; case "setRuleset": setRuleset(processes); break; case "exportDms": case "export": exportDms(processes, this.parameters.get("exportImages")); break; case "doit": case "doit2": exportDms(processes, String.valueOf(Boolean.FALSE)); break; case "runscript": String taskName = this.parameters.get("stepname"); String scriptName = this.parameters.get(SCRIPT); if (Objects.isNull(scriptName)) { Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "", "Missing parameter"); return false; } else { runScript(processes, taskName, scriptName); } break; case "deleteProcess": String value = parameters.get("contentOnly"); boolean contentOnly = true; if (Objects.nonNull(value) && value.equalsIgnoreCase("false")) { contentOnly = false; } deleteProcess(processes, contentOnly); break; default: Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "Unknown action", " - use: 'action:addRole, action:setTaskProperty, action:setStepStatus, " + "action:swapprozessesout, action:swapprozessesin, action:deleteTiffHeaderFile, " + "action:importFromFileSystem'"); return false; } return true; }
From source file:org.kitodo.api.dataformat.MediaUnit.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from ww w .j ava 2 s . co m*/ if (!(obj instanceof MediaUnit)) { return false; } MediaUnit other = (MediaUnit) obj; if (mediaFiles == null) { if (other.mediaFiles != null) { return false; } } else if (!mediaFiles.equals(other.mediaFiles)) { return false; } if (order != other.order) { return false; } if (orderlabel == null) { if (other.orderlabel != null) { return false; } } else if (!orderlabel.equals(other.orderlabel)) { return false; } if (Objects.isNull(type)) { return !Objects.nonNull(other.type); } else { return type.equals(other.type); } }