use of java.util.Objects in project robo4j by Robo4J.
the class RaspistillUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
Map<String, String> parameters = new HashMap<>();
parameters.put(KEY_WIDTH, configuration.getString(KEY_WIDTH, "320"));
parameters.put(KEY_HEIGHT, configuration.getString(KEY_HEIGHT, "240"));
parameters.put(KEY_EXPOSURE, configuration.getString(KEY_EXPOSURE, "sport"));
parameters.put(KEY_BRIGHTNESS, configuration.getString(KEY_BRIGHTNESS, null));
parameters.put(KEY_SHARPNESS, configuration.getString(KEY_SHARPNESS, null));
parameters.put(KEY_CONTRAST, configuration.getString(KEY_CONTRAST, null));
parameters.put(KEY_TIMEOUT, configuration.getString(KEY_TIMEOUT, "1"));
parameters.put(KEY_TIMELAPSE, configuration.getString(KEY_TIMELAPSE, "100"));
parameters.put(KEY_ROTATION, configuration.getString(KEY_ROTATION, null));
//@formatter:off
cameraCommand = new StringBuilder().append(RaspistillUtils.RASPISTILL_COMMAND).append(Constants.UTF8_SPACE).append(parameters.entrySet().stream().filter(p -> Objects.nonNull(p.getValue())).map(e -> {
StringBuilder c = new StringBuilder();
if (RaspistillUtils.isOption(e.getKey())) {
return c.append(RaspistillUtils.getOption(e.getKey())).append(Constants.UTF8_SPACE).append(e.getValue()).toString();
}
return null;
}).filter(Objects::nonNull).collect(Collectors.joining(Constants.UTF8_SPACE))).append(Constants.UTF8_SPACE).append(DEFAULT_IMAGE_SETUP).toString();
SimpleLoggingUtil.print(getClass(), "cameraCommand:" + cameraCommand);
//@formatter:on
targetOut = configuration.getString("targetOut", null);
String tmpClient = configuration.getString("client", null);
if (tmpClient == null || targetOut == null) {
throw ConfigurationException.createMissingConfigNameException("targetOut, client");
}
storeTarget = configuration.getString("storeTarget", null);
try {
InetAddress inetAddress = InetAddress.getByName(tmpClient);
String clientPort = configuration.getString("clientPort", null);
client = clientPort == null ? inetAddress.getHostAddress() : inetAddress.getHostAddress().concat(":").concat(clientPort);
clientUri = configuration.getString("clientUri", Constants.EMPTY_STRING);
} catch (UnknownHostException e) {
SimpleLoggingUtil.error(getClass(), "unknown ip address", e);
throw ConfigurationException.createMissingConfigNameException("unknown ip address");
}
}
use of java.util.Objects in project intellij-plugins by StepicOrg.
the class AbstractMoveHandlerDelegate method doMove.
@Override
public void doMove(Project project, PsiElement[] elements, @Nullable PsiElement targetContainer, @Nullable MoveCallback callback) {
List<PsiFileSystemItem> sources = Arrays.stream(elements).filter(psiElement -> isNotMovableOrRenameElement(psiElement, acceptableClasses)).map(ProjectPsiFilesUtils::getFile).filter(Objects::nonNull).collect(Collectors.toList());
StringBuilder message = new StringBuilder();
if (sources.size() > 1) {
message.append("You can not move the following elements:");
} else {
PsiFileSystemItem source = sources.get(0);
message.append("You can not move the ").append(source.isDirectory() ? "directory" : "file").append(":");
}
for (PsiFileSystemItem file : sources) {
message.append("\n").append(file.getVirtualFile().getPath());
}
MessagesEx.error(project, message.toString(), "Move").showNow();
}
use of java.util.Objects in project intellij-community by JetBrains.
the class PropertiesInheritorsSearcher method processQuery.
@Override
public void processQuery(@NotNull DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull Processor<PsiElement> consumer) {
final PsiElement element = queryParameters.getElement();
Property prop = ReadAction.compute(() -> GotoPropertyParentDeclarationHandler.findProperty(element));
if (prop == null || !(queryParameters.getScope() instanceof GlobalSearchScope)) {
return;
}
ReadAction.run(() -> {
final String key = prop.getKey();
if (!prop.isValid() || key == null)
return;
final PropertiesFile currentFile = PropertiesImplUtil.getPropertiesFile(prop.getContainingFile());
LOG.assertTrue(currentFile != null);
final GlobalSearchScope scope = (GlobalSearchScope) queryParameters.getScope();
currentFile.getResourceBundle().getPropertiesFiles().stream().filter(f -> f.equals(currentFile)).filter(f -> scope.contains(f.getVirtualFile())).filter(f -> PropertiesUtil.getParent(f, Collections.singleton(currentFile)) == currentFile).map(f -> f.findPropertyByKey(key)).filter(Objects::nonNull).map(IProperty::getPsiElement).anyMatch(psiElement -> {
ProgressManager.checkCanceled();
return !consumer.process(psiElement);
});
});
}
use of java.util.Objects in project EnrichmentMapApp by BaderLab.
the class CreateDiseaseSignatureNetworkTask method createHubNode.
/**
* Creates a signature hub node if it doesn't already exist.
* Otherwise it updates the attributes of the existing node.
*/
private void createHubNode(String hubName, CyNetwork network, CyNetworkView netView, String prefix, CyTable edgeTable, CyTable nodeTable, Set<Integer> geneUniverse, GeneSet sigGeneSet, EMSignatureDataSet sigDataSet) {
// Test for existing node first
CyNode hubNode = NetworkUtil.getNodeWithValue(network, nodeTable, CyNetwork.NAME, hubName);
if (hubNode == null) {
hubNode = network.addNode();
taskResult.addNewNode(hubNode);
}
sigDataSet.addNodeSuid(hubNode.getSUID());
network.getRow(hubNode).set(CyNetwork.NAME, hubName);
String formattedLabel = CreateEMNetworkTask.formatLabel(hubName);
CyRow row = nodeTable.getRow(hubNode.getSUID());
Columns.NODE_FORMATTED_NAME.set(row, prefix, null, formattedLabel);
List<String> geneList = sigGeneSet.getGenes().stream().map(map::getGeneFromHashKey).filter(Objects::nonNull).sorted().collect(Collectors.toList());
List<String> enrGeneList = sigGeneSet.getGenes().stream().filter(geneUniverse::contains).map(map::getGeneFromHashKey).filter(Objects::nonNull).sorted().collect(Collectors.toList());
Columns.NODE_GENES.set(row, prefix, null, geneList);
Columns.NODE_ENR_GENES.set(row, prefix, null, enrGeneList);
Columns.NODE_GS_DESCR.set(row, prefix, null, sigGeneSet.getDescription());
Columns.NODE_GS_TYPE.set(row, prefix, null, Columns.NODE_GS_TYPE_SIGNATURE);
Columns.NODE_NAME.set(row, prefix, null, sigGeneSet.getName());
Columns.NODE_GS_SIZE.set(row, prefix, null, sigGeneSet.getGenes().size());
// // Add the geneset of the signature node to the GenesetsOfInterest,
// // as the Heatmap will grep it's data from there.
// EMDataSet dataSet = map.getDataSet(dataSetName);
// Set<Integer> sigGenesInDataSet = ImmutableSet.copyOf(Sets.intersection(sigGeneSet.getGenes(), dataSet.getDataSetGenes()));
// GeneSet geneSetInDataSet = new GeneSet(sigGeneSet.getName(), sigGeneSet.getDescription(), sigGenesInDataSet);
// dataSet.getGeneSetsOfInterest().getGeneSets().put(hubName, geneSetInDataSet);
nodeCache.put(hubName, hubNode);
}
use of java.util.Objects in project geode by apache.
the class ClusterConfigurationService method downloadJarFromOtherLocators.
// used in the cluster config change listener when jarnames are changed in the internal region
public void downloadJarFromOtherLocators(String groupName, String jarName) throws IllegalStateException, IOException {
logger.info("Getting Jar files from other locators");
DM dm = this.cache.getDistributionManager();
DistributedMember me = this.cache.getMyId();
Set<DistributedMember> locators = new HashSet<>(dm.getAllHostedLocatorsWithSharedConfiguration().keySet());
locators.remove(me);
createConfigDirIfNecessary(groupName);
byte[] jarBytes = locators.stream().map((DistributedMember locator) -> downloadJarFromLocator(locator, groupName, jarName)).filter(Objects::nonNull).findFirst().orElseThrow(() -> new IllegalStateException("No locators have a deployed jar named " + jarName + " in " + groupName));
File jarToWrite = getPathToJarOnThisLocator(groupName, jarName).toFile();
FileUtils.writeByteArrayToFile(jarToWrite, jarBytes);
}
Aggregations