use of java.util.function.Predicate in project kie-wb-common by kiegroup.
the class AbstractProcessFilteredNodeProvider method findElements.
protected Collection<Pair<Object, String>> findElements(final Predicate<Node> filter, final Function<Node, Pair<Object, String>> mapper) {
final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
@SuppressWarnings("unchecked") Iterable<Node> it = diagram.getGraph().nodes();
return StreamSupport.stream(it.spliterator(), false).filter(filter).map(mapper).filter(pair -> pair != null).collect(Collectors.toSet());
}
use of java.util.function.Predicate in project ArachneCentralAPI by OHDSI.
the class WebSecurityConfig method urlToHostUrlMapConverter.
public static LinkedHashMap<String, URI> urlToHostUrlMapConverter(List<String> portalUrlWhiteList) {
final Pattern urlPattern = Pattern.compile("(https?://)([^:^/]*)(:\\\\d*)?(.*)?");
final Predicate<String> urlFilterPredicate = s -> {
final Matcher matcher = urlPattern.matcher(s);
return matcher.matches();
};
return portalUrlWhiteList.stream().filter(urlFilterPredicate).map(URI::create).collect(Collectors.toMap(URI::getHost, s -> s, (host1, host2) -> host1, LinkedHashMap::new));
}
use of java.util.function.Predicate in project engineblock by engineblock.
the class CoreServices method getInputDispenser.
// public static <A extends Activity> Optional<IntPredicateDispenser> getResultFilterDispenser(A activity) {
// Optional<IntPredicateDispenser> intPredicateDispenser = new SimpleConfig(activity, "resultfilter")
// .getString("type")
// .flatMap(ExperimentalResultFilterType.FINDER::get)
// .map(rft -> rft.getFilterDispenser(activity));
// return intPredicateDispenser;
// }
//
public static <A extends Activity> InputDispenser getInputDispenser(A activity) {
String inputTypeName = new SimpleConfig(activity, "input").getString("type").orElse("targetrate");
InputType inputType = InputType.FINDER.getOrThrow(inputTypeName);
InputDispenser dispenser = inputType.getInputDispenser(activity);
Optional<Predicate<ResultReadable>> inputFilterDispenser = getInputFilter(activity);
if (inputFilterDispenser.isPresent()) {
dispenser = new FilteringInputDispenser(dispenser, inputFilterDispenser.get());
}
return dispenser;
}
use of java.util.function.Predicate in project oap by oaplatform.
the class MemoryStorage method updateObject.
protected Optional<? extends Metadata<T>> updateObject(String id, Predicate<T> predicate, Function<T, T> update, Supplier<T> init) {
return lockStrategy.synchronizedOn(id, () -> {
Metadata<T> metadata = data.get(id);
if (metadata == null) {
if (init == null)
return Optional.empty();
metadata = data.computeIfAbsent(id, (id1) -> {
val object = init.get();
identifier.set(object, id);
checkConstraints(object);
return new Metadata<>(object);
});
data.put(id, metadata);
metadata.setUpdated();
} else {
if (predicate.test(metadata.object)) {
val newObject = update.apply(Binder.json.clone(metadata.object));
checkConstraints(newObject);
identifier.set(newObject, id);
metadata.update(newObject);
} else {
return Optional.empty();
}
}
return Optional.of(metadata);
});
}
use of java.util.function.Predicate in project vorto by eclipse.
the class GeneratorMojo method loadInformationModels.
private byte[] loadInformationModels() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ZipOutputStream zaos = new ZipOutputStream(baos);
Files.walk(Paths.get((project.getBasedir().toURI()))).filter(new Predicate<Path>() {
public boolean test(Path path) {
return !path.toFile().isDirectory() && (path.getFileName().toString().endsWith(ModelType.InformationModel.getExtension()) || path.getFileName().toString().endsWith(ModelType.Functionblock.getExtension()) || path.getFileName().toString().endsWith(ModelType.Datatype.getExtension()) || path.getFileName().toString().endsWith(ModelType.Mapping.getExtension()));
}
}).forEach(new Consumer<Path>() {
public void accept(Path t) {
addToZip(zaos, t);
}
});
return baos.toByteArray();
}
Aggregations