1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
package com.sun.javafx.runtime.location; |
27 | |
|
28 | |
import com.sun.javafx.functions.Function0; |
29 | |
import com.sun.javafx.functions.Function1; |
30 | |
import com.sun.javafx.runtime.Util; |
31 | |
import com.sun.javafx.runtime.sequence.*; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class BoundOperators extends GeneratedBoundOperators { |
40 | |
|
41 | 0 | private BoundOperators() { } |
42 | |
|
43 | |
public static <T, V> BooleanLocation eq_oo(final ObjectLocation<T> a, final ObjectLocation<V> b) { |
44 | 18 | return BooleanVariable.make(new BooleanBindingExpression() { |
45 | |
public boolean computeValue() { |
46 | 20 | T aVal = a.get(); |
47 | 20 | V bVal = b.get(); |
48 | 20 | if (aVal == null) |
49 | 20 | return bVal == null; |
50 | |
else |
51 | 0 | return aVal.equals(bVal); |
52 | |
} |
53 | |
}, a, b); |
54 | |
} |
55 | |
|
56 | |
public static <T, V> BooleanLocation ne_oo(final ObjectLocation<T> a, final ObjectLocation<V> b) { |
57 | 16 | return BooleanVariable.make(new BooleanBindingExpression() { |
58 | |
public boolean computeValue() { |
59 | 16 | T aVal = a.get(); |
60 | 16 | V bVal = b.get(); |
61 | 16 | if (aVal == null) |
62 | 2 | return bVal != null; |
63 | |
else |
64 | 14 | return !aVal.equals(bVal); |
65 | |
} |
66 | |
}, a, b); |
67 | |
} |
68 | |
|
69 | |
public static <T, V> BooleanLocation eq_ss(final SequenceLocation<T> a, final SequenceLocation<V> b) { |
70 | 0 | return BooleanVariable.make(new BooleanBindingExpression() { |
71 | |
public boolean computeValue() { |
72 | 0 | Sequence<T> aVal = a.getAsSequence(); |
73 | 0 | Sequence<V> bVal = b.getAsSequence(); |
74 | 0 | if (aVal == null) |
75 | 0 | return bVal == null; |
76 | |
else |
77 | 0 | return aVal.equals(bVal); |
78 | |
} |
79 | |
}, a, b); |
80 | |
} |
81 | |
|
82 | |
public static <T, V> BooleanLocation ne_ss(final SequenceLocation<T> a, final SequenceLocation<V> b) { |
83 | 0 | return BooleanVariable.make(new BooleanBindingExpression() { |
84 | |
public boolean computeValue() { |
85 | 0 | Sequence<T> aVal = a.getAsSequence(); |
86 | 0 | Sequence<V> bVal = b.getAsSequence(); |
87 | 0 | if (aVal == null) |
88 | 0 | return bVal != null; |
89 | |
else |
90 | 0 | return !aVal.equals(bVal); |
91 | |
} |
92 | |
}, a, b); |
93 | |
} |
94 | |
|
95 | |
|
96 | |
public static IntLocation makeBoundIf(boolean lazy, |
97 | |
final BooleanLocation conditional, |
98 | |
final Function0<IntLocation> thenBranch, |
99 | |
final Function0<IntLocation> elseBranch) { |
100 | 14 | return new IndirectIntExpression(lazy, conditional) { |
101 | |
protected IntLocation computeLocation() { |
102 | 17 | return (conditional.get()) ? thenBranch.invoke() : elseBranch.invoke(); |
103 | |
} |
104 | |
}; |
105 | |
} |
106 | |
|
107 | |
public static DoubleLocation makeBoundIf(boolean lazy, |
108 | |
final BooleanLocation conditional, |
109 | |
final Function0<DoubleLocation> thenBranch, |
110 | |
final Function0<DoubleLocation> elseBranch) { |
111 | 0 | return new IndirectDoubleExpression(lazy, conditional) { |
112 | |
protected DoubleLocation computeLocation() { |
113 | 0 | return (conditional.get()) ? thenBranch.invoke() : elseBranch.invoke(); |
114 | |
} |
115 | |
}; |
116 | |
} |
117 | |
|
118 | |
public static BooleanLocation makeBoundIf(boolean lazy, |
119 | |
final BooleanLocation conditional, |
120 | |
final Function0<BooleanLocation> thenBranch, |
121 | |
final Function0<BooleanLocation> elseBranch) { |
122 | 4 | return new IndirectBooleanExpression(lazy, conditional) { |
123 | |
protected BooleanLocation computeLocation() { |
124 | 4 | return (conditional.get()) ? thenBranch.invoke() : elseBranch.invoke(); |
125 | |
} |
126 | |
}; |
127 | |
} |
128 | |
|
129 | |
public static<T> ObjectLocation<T> makeBoundIf(boolean lazy, |
130 | |
final BooleanLocation conditional, |
131 | |
final Function0<ObjectLocation<T>> thenBranch, |
132 | |
final Function0<ObjectLocation<T>> elseBranch) { |
133 | 42 | return new IndirectObjectExpression<T>(lazy, conditional) { |
134 | |
protected ObjectLocation<T> computeLocation() { |
135 | 54 | return (conditional.get()) ? thenBranch.invoke() : elseBranch.invoke(); |
136 | |
} |
137 | |
}; |
138 | |
} |
139 | |
|
140 | |
public static<T> SequenceLocation<T> makeBoundIf(Class<T> clazz, |
141 | |
boolean lazy, |
142 | |
final BooleanLocation conditional, |
143 | |
final Function0<SequenceLocation<T>> thenBranch, |
144 | |
final Function0<SequenceLocation<T>> elseBranch) { |
145 | 403 | return new IndirectSequenceExpression<T>(clazz, lazy, conditional) { |
146 | |
protected SequenceLocation<T> computeLocation() { |
147 | 914 | return (conditional.get()) ? thenBranch.invoke() : elseBranch.invoke(); |
148 | |
} |
149 | |
}; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
public static<T> IntLocation makeBoundSelect(boolean lazy, |
154 | |
final ObjectLocation<T> receiver, |
155 | |
final Function1<IntLocation, T> selector) { |
156 | 11 | return new IndirectIntExpression(lazy, receiver) { |
157 | |
protected IntLocation computeLocation() { |
158 | 24 | T selectorValue = receiver.get(); |
159 | 24 | return selectorValue == null ? IntConstant.make(DEFAULT) : selector.invoke(selectorValue); |
160 | |
} |
161 | |
|
162 | |
public int setAsInt(int value) { |
163 | |
|
164 | 1 | return helper.get().setAsInt(value); |
165 | |
} |
166 | |
|
167 | |
public void setDefault() { |
168 | 0 | helper.get().setDefault(); |
169 | 0 | } |
170 | |
|
171 | |
public Integer set(Integer value) { |
172 | 0 | return helper.get().set(value); |
173 | |
} |
174 | |
}; |
175 | |
} |
176 | |
|
177 | |
public static<T> DoubleLocation makeBoundSelect(boolean lazy, |
178 | |
final ObjectLocation<T> receiver, |
179 | |
final Function1<DoubleLocation, T> selector) { |
180 | 6 | return new IndirectDoubleExpression(lazy, receiver) { |
181 | |
protected DoubleLocation computeLocation() { |
182 | 26 | T selectorValue = receiver.get(); |
183 | 26 | return selectorValue == null ? DoubleConstant.make(DEFAULT) : selector.invoke(selectorValue); |
184 | |
} |
185 | |
|
186 | |
public double setAsDouble(double value) { |
187 | |
|
188 | 0 | return helper.get().setAsDouble(value); |
189 | |
} |
190 | |
|
191 | |
public void setDefault() { |
192 | 0 | helper.get().setDefault(); |
193 | 0 | } |
194 | |
|
195 | |
public Double set(Double value) { |
196 | 0 | return helper.get().set(value); |
197 | |
} |
198 | |
}; |
199 | |
} |
200 | |
|
201 | |
public static<T> BooleanLocation makeBoundSelect(boolean lazy, |
202 | |
final ObjectLocation<T> receiver, |
203 | |
final Function1<BooleanLocation, T> selector) { |
204 | 3 | return new IndirectBooleanExpression(lazy, receiver) { |
205 | |
protected BooleanLocation computeLocation() { |
206 | 9 | T selectorValue = receiver.get(); |
207 | 9 | return selectorValue == null ? BooleanConstant.make(DEFAULT) : selector.invoke(selectorValue); |
208 | |
} |
209 | |
|
210 | |
public boolean setAsBoolean(boolean value) { |
211 | |
|
212 | 0 | return helper.get().setAsBoolean(value); |
213 | |
} |
214 | |
|
215 | |
public void setDefault() { |
216 | 0 | helper.get().setDefault(); |
217 | 0 | } |
218 | |
|
219 | |
public Boolean set(Boolean value) { |
220 | 0 | return helper.get().set(value); |
221 | |
} |
222 | |
}; |
223 | |
} |
224 | |
|
225 | |
public static<T, U> ObjectLocation<U> makeBoundSelect(final Class clazz, |
226 | |
boolean lazy, |
227 | |
final ObjectLocation<T> receiver, |
228 | |
final Function1<ObjectLocation<U>, T> selector) { |
229 | 22 | return new IndirectObjectExpression<U>(lazy, receiver) { |
230 | |
|
231 | |
protected ObjectLocation<U> computeLocation() { |
232 | 40 | T selectorValue = receiver.get(); |
233 | 40 | return selectorValue == null ? ObjectConstant.make(Util.<U>defaultValue(clazz)) : selector.invoke(selectorValue); |
234 | |
} |
235 | |
|
236 | |
public void setDefault() { |
237 | 0 | helper.get().setDefault(); |
238 | 0 | } |
239 | |
|
240 | |
public U set(U value) { |
241 | |
|
242 | 0 | return helper.get().set(value); |
243 | |
} |
244 | |
}; |
245 | |
} |
246 | |
|
247 | |
public static<T, U> SequenceLocation<U> makeBoundSelect(final Class<U> clazz, |
248 | |
boolean lazy, |
249 | |
final ObjectLocation<T> receiver, |
250 | |
final Function1<SequenceLocation<U>, T> selector) { |
251 | |
|
252 | 1 | final SequenceLocation<U> defaultValue = SequenceConstant.<U>make(Sequences.emptySequence(clazz)); |
253 | |
|
254 | 1 | return new IndirectSequenceExpression<U>(clazz, lazy, receiver) { |
255 | |
|
256 | |
|
257 | |
|
258 | |
protected SequenceLocation<U> computeLocation() { |
259 | 5 | T selectorValue = receiver.get(); |
260 | 5 | return selectorValue == null ? defaultValue : selector.invoke(selectorValue); |
261 | |
} |
262 | |
|
263 | |
public void setDefault() { |
264 | 0 | helper.get().setDefault(); |
265 | 0 | } |
266 | |
|
267 | |
public Sequence<U> setAsSequence(Sequence<? extends U> value) { |
268 | |
|
269 | 0 | return helper.get().setAsSequence(value); |
270 | |
} |
271 | |
|
272 | |
public Sequence<U> set(Sequence<U> value) { |
273 | 0 | return helper.get().set(value); |
274 | |
} |
275 | |
|
276 | |
public U set(int position, U newValue) { |
277 | 0 | return helper.get().set(position, newValue); |
278 | |
} |
279 | |
|
280 | |
public Sequence<? extends U> replaceSlice(int startPos, int endPos, Sequence<? extends U> newValues) { |
281 | 0 | return helper.get().replaceSlice(startPos, endPos, newValues); |
282 | |
} |
283 | |
|
284 | |
public void delete(int position) { |
285 | 0 | helper.get().delete(position); |
286 | 0 | } |
287 | |
|
288 | |
public void deleteSlice(int startPos, int endPos) { |
289 | 0 | helper.get().deleteSlice(startPos, endPos); |
290 | 0 | } |
291 | |
|
292 | |
public void delete(SequencePredicate<U> tSequencePredicate) { |
293 | 0 | helper.get().delete(tSequencePredicate); |
294 | 0 | } |
295 | |
|
296 | |
public void deleteAll() { |
297 | 0 | helper.get().deleteAll(); |
298 | 0 | } |
299 | |
|
300 | |
public void deleteValue(U targetValue) { |
301 | 0 | helper.get().deleteValue(targetValue); |
302 | 0 | } |
303 | |
|
304 | |
public void insert(U value) { |
305 | 0 | helper.get().insert(value); |
306 | 0 | } |
307 | |
|
308 | |
public void insert(Sequence<? extends U> values) { |
309 | 0 | helper.get().insert(values); |
310 | 0 | } |
311 | |
|
312 | |
public void insertFirst(U value) { |
313 | 0 | helper.get().insertFirst(value); |
314 | 0 | } |
315 | |
|
316 | |
public void insertFirst(Sequence<? extends U> values) { |
317 | 0 | helper.get().insertFirst(values); |
318 | 0 | } |
319 | |
|
320 | |
public void insertBefore(U value, int position) { |
321 | 0 | helper.get().insertBefore(value, position); |
322 | 0 | } |
323 | |
|
324 | |
public void insertBefore(U value, SequencePredicate<U> tSequencePredicate) { |
325 | 0 | helper.get().insertBefore(value, tSequencePredicate); |
326 | 0 | } |
327 | |
|
328 | |
public void insertBefore(Sequence<? extends U> values, int position) { |
329 | 0 | helper.get().insertBefore(values, position); |
330 | 0 | } |
331 | |
|
332 | |
public void insertBefore(Sequence<? extends U> values, SequencePredicate<U> tSequencePredicate) { |
333 | 0 | helper.get().insertBefore(values, tSequencePredicate); |
334 | 0 | } |
335 | |
|
336 | |
public void insertAfter(U value, int position) { |
337 | 0 | helper.get().insertAfter(value, position); |
338 | 0 | } |
339 | |
|
340 | |
public void insertAfter(U value, SequencePredicate<U> tSequencePredicate) { |
341 | 0 | helper.get().insertAfter(value, tSequencePredicate); |
342 | 0 | } |
343 | |
|
344 | |
public void insertAfter(Sequence<? extends U> values, int position) { |
345 | 0 | helper.get().insertAfter(values, position); |
346 | 0 | } |
347 | |
|
348 | |
public void insertAfter(Sequence<? extends U> values, SequencePredicate<U> tSequencePredicate) { |
349 | 0 | helper.get().insertAfter(values, tSequencePredicate); |
350 | 0 | } |
351 | |
}; |
352 | |
} |
353 | |
|
354 | |
} |