.values() .forEach(list -> list.addListener(onListChange));
/** * {@inheritDoc} */ @Override public Collection<ServiceTask<?>> getPendingTaskList() { return this.pendingTasks.values(); }
private void updateAllSelectionShapes() { selections.values().forEach(this::updateSingleSelection); }
@Nonnull @Override protected Stream createStream() { return ((ObservableMap) observable).values().stream(); } }
private void addDirectMessages(final List<DirectMessage> loadedMessages) { final var knownMessages = messageEvents.values() .stream() .flatMap(List::stream) .collect(Collectors.toList()); final var newMessages = loadedMessages.stream() .filter(((Predicate<DirectMessage>) knownMessages::contains).negate()) .collect(Collectors.toList()); LOG.debug("Loaded {} new messages", newMessages.size()); newMessages.forEach(this::addDirectMessage); }
/** * Creates a number binding that contains the sum of the values of the given observable map. * * @param items the observable map of items. * * @return a number binding. */ @Nonnull public static <K> NumberBinding sumOfMap(@Nonnull final ObservableMap<K, ? extends Number> items) { requireNonNull(items, ERROR_ITEMS_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).sum(), items); }
@Override public Collection<V> values() { return getDelegate().values(); }
/** * Creates a boolean binding based on a <tt>noneMatch</tt> predicate applied to the items. * * @param items the observable map of items. * @param predicate a non-interfering, stateless predicate to apply to the each element. * * @return a boolean binding */ @Nonnull public static <K, V> BooleanBinding noneMatch(@Nonnull final ObservableMap<K, V> items, @Nonnull final Predicate<? super V> predicate) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(predicate, ERROR_PREDICATE_NULL); return createBooleanBinding(() -> items.values().stream().noneMatch(predicate), items); }
/** * Creates a boolean binding based on a <tt>anyMatch</tt> predicate applied to the items. * * @param items the observable map of items. * @param predicate a non-interfering, stateless predicate to apply to the each element. * * @return a boolean binding */ @Nonnull public static <K, V> BooleanBinding anyMatch(@Nonnull final ObservableMap<K, V> items, @Nonnull final Predicate<? super V> predicate) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(predicate, ERROR_PREDICATE_NULL); return createBooleanBinding(() -> items.values().stream().anyMatch(predicate), items); }
/** * Creates a number binding that contains the sum of the values of the given observable map. * * @param items the observable map of items. * @param mapper a non-interfering, stateless function to apply to the each value. * * @return a number binding. */ @Nonnull public static <K, V> NumberBinding sumOfMap(@Nonnull final ObservableMap<K, V> items, @Nonnull final ToDoubleFunction<? super V> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(mapper).sum(), items); }
/** * Creates a float binding with the first value of an observable map after filtering. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each value * * @return a float binding */ @Nonnull public static <K> FloatBinding filterThenFindFirstFloat(@Nonnull final ObservableMap<K, Float> items, @Nonnull final Float defaultValue, @Nonnull final Predicate<? super Float> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createFloatBinding(() -> items.values().stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Creates an object binding with the first value of an observable map after filtering. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each value * * @return an object binding */ @Nonnull public static <K, V> ObjectBinding<V> filterThenFindFirst(@Nonnull final ObservableMap<K, V> items, @Nonnull final V defaultValue, @Nonnull final Predicate<? super V> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createObjectBinding(() -> items.values().stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Creates a long binding with the first value of an observable map after filtering. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each value * * @return a long binding */ @Nonnull public static <K> LongBinding filterThenFindFirstLong(@Nonnull final ObservableMap<K, Long> items, @Nonnull final Long defaultValue, @Nonnull final Predicate<? super Long> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createLongBinding(() -> items.values().stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Creates a number binding that computes the maximum value amongst values. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static <K> NumberBinding maxInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).max().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the minimum value amongst values. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static <K> NumberBinding minInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).min().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the average value amongst values. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static <K> NumberBinding averageInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).average().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the maximum value amongst values. * * @param items the observable map of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * * @return a number binding */ @Nonnull public static <K> NumberBinding maxInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Supplier<? extends Number> supplier) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).max().orElseGet(resolveDoubleSupplier(supplier)), items); }
/** * Creates a number binding that computes the average value amongst values. * * @param items the observable map of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * * @return a number binding */ @Nonnull public static <K> NumberBinding averageInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Supplier<? extends Number> supplier) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).average().orElseGet(resolveDoubleSupplier(supplier)), items); }
@Override protected boolean computeValue() { if (availableMap.isEmpty()) { return false; } for (IntegerProperty amount : availableMap.values()) { if (amount.get() > 0) { return true; } } return false; } };
/** * Creates validation support instance. <br> * If initial decoration is desired invoke {@link #initInitialDecoration()}. */ public ValidationSupport() { validationResultProperty().addListener( (o, oldValue, validationResult) -> { invalidProperty.set(!validationResult.getErrors().isEmpty()); redecorate(); }); // notify validation result observers validationResults.addListener( (MapChangeListener.Change<? extends Control, ? extends ValidationResult> change) -> validationResultProperty.set(ValidationResult.fromResults(validationResults.values())) ); }