001 /*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2008-2017 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 @Nonnull
040 ObservableStream<T> limit(long maxSize);
041
042 @Nonnull
043 ObservableStream<T> limit(@Nonnull ObservableLongValue maxSize);
044
045 @Nonnull
046 ObservableStream<T> skip(long n);
047
048 @Nonnull
049 ObservableStream<T> skip(@Nonnull ObservableLongValue n);
050
051 @Nonnull
052 ObservableStream<T> distinct();
053
054 @Nonnull
055 ObservableStream<T> sorted();
056
057 @Nonnull
058 ObservableStream<T> sorted(@Nonnull Comparator<? super T> comparator);
059
060 @Nonnull
061 ObservableStream<T> sorted(@Nonnull ObservableValue<Comparator<? super T>> comparator);
062
063 @Nonnull
064 ObservableStream<T> filter(@Nonnull Predicate<? super T> predicate);
065
066 @Nonnull
067 <R> ObservableStream<R> map(@Nonnull Function<? super T, ? extends R> mapper);
068
069 @Nonnull
070 <R> ObservableStream<R> flatMap(@Nonnull Function<? super T, ? extends ObservableStream<? extends R>> mapper);
071
072 @Nonnull
073 ObservableStream<T> filter(@Nonnull ObservableValue<Predicate<? super T>> predicate);
074
075 @Nonnull
076 <R> ObservableStream<R> map(@Nonnull ObservableValue<Function<? super T, ? extends R>> mapper);
077
078 @Nonnull
079 <R> ObservableStream<R> flatMap(@Nonnull ObservableValue<Function<? super T, ? extends ObservableStream<? extends R>>> mapper);
080
081 @Nonnull
082 ObjectBinding<T> reduce(@Nonnull BinaryOperator<T> accumulator);
083
084 @Nonnull
085 ObjectBinding<T> reduce(@Nullable T defaultValue, @Nonnull BinaryOperator<T> accumulator);
086
087 @Nonnull
088 ObjectBinding<T> reduce(@Nonnull Supplier<T> supplier, @Nonnull BinaryOperator<T> accumulator);
089
090 @Nonnull
091 <U> ObjectBinding<U> reduce(@Nullable U identity, @Nonnull BiFunction<U, ? super T, U> accumulator, @Nonnull BinaryOperator<U> combiner);
092
093 @Nonnull
094 ObjectBinding<T> reduce(@Nonnull ObservableValue<BinaryOperator<T>> accumulator);
095
096 @Nonnull
097 ObjectBinding<T> reduce(@Nullable T defaultValue, @Nonnull ObservableValue<BinaryOperator<T>> accumulator);
098
099 @Nonnull
100 ObjectBinding<T> reduce(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<BinaryOperator<T>> accumulator);
101
102 @Nonnull
103 <U> ObjectBinding<U> reduce(@Nonnull ObservableValue<U> identity, @Nonnull ObservableValue<BiFunction<U, ? super T, U>> accumulator, @Nonnull ObservableValue<BinaryOperator<U>> combiner);
104
105 @Nonnull
106 ObjectBinding<T> min(@Nonnull Comparator<? super T> comparator);
107
108 @Nonnull
109 ObjectBinding<T> max(@Nonnull Comparator<? super T> comparator);
110
111 @Nonnull
112 ObjectBinding<T> min(@Nullable T defaultValue, @Nonnull Comparator<? super T> comparator);
113
114 @Nonnull
115 ObjectBinding<T> max(@Nullable T defaultValue, @Nonnull Comparator<? super T> comparator);
116
117 @Nonnull
118 ObjectBinding<T> min(@Nonnull Supplier<T> supplier, @Nonnull Comparator<? super T> comparator);
119
120 @Nonnull
121 ObjectBinding<T> max(@Nonnull Supplier<T> supplier, @Nonnull Comparator<? super T> comparator);
122
123 @Nonnull
124 BooleanBinding anyMatch(@Nonnull Predicate<? super T> predicate);
125
126 @Nonnull
127 BooleanBinding allMatch(@Nonnull Predicate<? super T> predicate);
128
129 @Nonnull
130 BooleanBinding noneMatch(@Nonnull Predicate<? super T> predicate);
131
132 @Nonnull
133 ObjectBinding<T> min(@Nonnull ObservableValue<Comparator<? super T>> comparator);
134
135 @Nonnull
136 ObjectBinding<T> max(@Nonnull ObservableValue<Comparator<? super T>> comparator);
137
138 @Nonnull
139 ObjectBinding<T> min(@Nullable T defaultValue, @Nonnull ObservableValue<Comparator<? super T>> comparator);
140
141 @Nonnull
142 ObjectBinding<T> max(@Nullable T defaultValue, @Nonnull ObservableValue<Comparator<? super T>> comparator);
143
144 @Nonnull
145 ObjectBinding<T> min(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<Comparator<? super T>> comparator);
146
147 @Nonnull
148 ObjectBinding<T> max(@Nonnull Supplier<T> supplier, @Nonnull ObservableValue<Comparator<? super T>> comparator);
149
150 @Nonnull
151 BooleanBinding anyMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
152
153 @Nonnull
154 BooleanBinding allMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
155
156 @Nonnull
157 BooleanBinding noneMatch(@Nonnull ObservableValue<Predicate<? super T>> predicate);
158
159 @Nonnull
160 ObjectBinding<T> findFirst();
161
162 @Nonnull
163 ObjectBinding<T> findFirst(@Nullable T defaultValue);
164
165 @Nonnull
166 ObjectBinding<T> findFirst(@Nonnull Supplier<T> supplier);
167
168 @Nonnull
169 ObjectBinding<T> findAny();
170
171 @Nonnull
172 ObjectBinding<T> findAny(@Nullable T defaultValue);
173
174 @Nonnull
175 ObjectBinding<T> findAny(@Nonnull Supplier<T> supplier);
176 }
|