001 /*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2008-2021 the original author or authors.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package griffon.javafx.collections;
019
020 import javafx.beans.binding.BooleanBinding;
021 import javafx.beans.binding.ObjectBinding;
022 import javafx.beans.value.ObservableLongValue;
023 import javafx.beans.value.ObservableValue;
024
025 import javax.annotation.Nonnull;
026 import javax.annotation.Nullable;
027 import java.util.Comparator;
028 import java.util.function.BiFunction;
029 import java.util.function.BinaryOperator;
030 import java.util.function.Function;
031 import java.util.function.Predicate;
032 import java.util.function.Supplier;
033
034 /**
035 * @author Andres Almiray
036 * @since 2.13.0
037 */
038 public interface ObservableStream<T> {
039 ObservableStream<T> limit(long maxSize);
040
041 ObservableStream<T> limit(@Nonnull ObservableLongValue maxSize);
042
043 ObservableStream<T> skip(long n);
044
045 ObservableStream<T> skip(@Nonnull ObservableLongValue n);
046
047 ObservableStream<T> distinct();
048
049 ObservableStream<T> sorted();
050
051 ObservableStream<T> sorted(@Nonnull Comparator<? super T> comparator);
052
053 ObservableStream<T> sorted(@Nonnull ObservableValue<Comparator<? super T>> comparator);
054
055 ObservableStream<T> filter(@Nonnull Predicate<? super T> predicate);
056
057 <R> ObservableStream<R> map(@Nonnull Function<? super T, ? extends R> mapper);
058
059 <R> ObservableStream<R> flatMap(@Nonnull Function<? super T, ? extends ObservableStream<? extends R>> mapper);
060
061 ObservableStream<T> filter(@Nonnull ObservableValue<Predicate<? super T>> predicate);
062
063 <R> ObservableStream<R> map(@Nonnull ObservableValue<Function<? super T, ? extends R>> mapper);
064
065 <R> ObservableStream<R> flatMap(@Nonnull ObservableValue<Function<? super T, ? extends ObservableStream<? extends R>>> mapper);
066
067 ObjectBinding<T> reduce(@Nonnull BinaryOperator<T> accumulator);
068
069 ObjectBinding<T> reduce(@Nullable T defaultValue, @Nonnull BinaryOperator<T> accumulator);
070
071 ObjectBinding<T> reduce(@Nonnull Supplier<T> supplier, @Nonnull BinaryOperator<T> accumulator);
072
073 <U> ObjectBinding<U> reduce(@Nullable U identity, @Nonnull BiFunction<U, ? super T, U> accumulator, @Nonnull BinaryOperator<U> combiner);
074
075 ObjectBinding<T> reduce(@Nonnull ObservableValue<BinaryOperator<T>> accumulator);
076
077 ObjectBinding<T> reduce(@Nullable T defaultValue, @Nonnull ObservableValue<BinaryOperator<T>> accumulator);
078
079 ObjectBinding<T> reduce(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<BinaryOperator<T>> accumulator);
080
081 <U> ObjectBinding<U> reduce(@Nonnull ObservableValue<U> identity, @Nonnull ObservableValue<BiFunction<U, ? super T, U>> accumulator, @Nonnull ObservableValue<BinaryOperator<U>> combiner);
082
083 ObjectBinding<T> min(@Nonnull Comparator<? super T> comparator);
084
085 ObjectBinding<T> max(@Nonnull Comparator<? super T> comparator);
086
087 ObjectBinding<T> min(@Nullable T defaultValue, @Nonnull Comparator<? super T> comparator);
088
089 ObjectBinding<T> max(@Nullable T defaultValue, @Nonnull Comparator<? super T> comparator);
090
091 ObjectBinding<T> min(@Nonnull Supplier<T> supplier, @Nonnull Comparator<? super T> comparator);
092
093 ObjectBinding<T> max(@Nonnull Supplier<T> supplier, @Nonnull Comparator<? super T> comparator);
094
095 BooleanBinding anyMatch(@Nonnull Predicate<? super T> predicate);
096
097 BooleanBinding allMatch(@Nonnull Predicate<? super T> predicate);
098
099 BooleanBinding noneMatch(@Nonnull Predicate<? super T> predicate);
100
101 ObjectBinding<T> min(@Nonnull ObservableValue<Comparator<? super T>> comparator);
102
103 ObjectBinding<T> max(@Nonnull ObservableValue<Comparator<? super T>> comparator);
104
105 ObjectBinding<T> min(@Nullable T defaultValue, @Nonnull ObservableValue<Comparator<? super T>> comparator);
106
107 ObjectBinding<T> max(@Nullable T defaultValue, @Nonnull ObservableValue<Comparator<? super T>> comparator);
108
109 ObjectBinding<T> min(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<Comparator<? super T>> comparator);
110
111 ObjectBinding<T> max(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<Comparator<? super T>> comparator);
112
113 BooleanBinding anyMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
114
115 BooleanBinding allMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
116
117 BooleanBinding noneMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
118
119 ObjectBinding<T> findFirst();
120
121 ObjectBinding<T> findFirst(@Nullable T defaultValue);
122
123 ObjectBinding<T> findFirst(@Nonnull Supplier<T> supplier);
124
125 ObjectBinding<T> findAny();
126
127 ObjectBinding<T> findAny(@Nullable T defaultValue);
128
129 ObjectBinding<T> findAny(@Nonnull Supplier<T> supplier);
130 }
|