1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.functor.core.composite;
18
19 import org.apache.commons.functor.BinaryFunction;
20 import org.apache.commons.functor.BinaryPredicate;
21 import org.apache.commons.functor.BinaryProcedure;
22 import org.apache.commons.functor.Function;
23 import org.apache.commons.functor.Predicate;
24 import org.apache.commons.functor.Procedure;
25 import org.apache.commons.functor.UnaryFunction;
26 import org.apache.commons.functor.UnaryPredicate;
27 import org.apache.commons.functor.UnaryProcedure;
28
29
30
31
32
33
34 public final class Conditional {
35
36
37
38
39
40
41
42
43
44
45
46
47 public Conditional() { }
48
49
50
51
52
53
54
55
56
57 public static Procedure procedure(Predicate q, Procedure r) {
58 return new ConditionalProcedure(q, r);
59 }
60
61
62
63
64
65
66
67
68 public static Procedure procedure(Predicate q, Procedure r, Procedure s) {
69 return new ConditionalProcedure(q, r, s);
70 }
71
72
73
74
75
76
77
78
79 public static <T> Function<T> function(Predicate q, Function<? extends T> r, Function<? extends T> s) {
80 return new ConditionalFunction<T>(q, r, s);
81 }
82
83
84
85
86
87
88
89
90 public static Predicate predicate(Predicate q, Predicate r, Predicate s) {
91 return new ConditionalPredicate(q, r, s);
92 }
93
94
95
96
97
98
99
100 public static <A> UnaryProcedure<A> procedure(UnaryPredicate<? super A> q, UnaryProcedure<? super A> r) {
101 return new ConditionalUnaryProcedure<A>(q, r);
102 }
103
104
105
106
107
108
109
110
111 public static <A> UnaryProcedure<A> procedure(UnaryPredicate<? super A> q, UnaryProcedure<? super A> r,
112 UnaryProcedure<? super A> s) {
113 return new ConditionalUnaryProcedure<A>(q, r, s);
114 }
115
116
117
118
119
120
121
122
123 public static <A, T> UnaryFunction<A, T> function(UnaryPredicate<? super A> q,
124 UnaryFunction<? super A, ? extends T> r, UnaryFunction<? super A, ? extends T> s) {
125 return new ConditionalUnaryFunction<A, T>(q, r, s);
126 }
127
128
129
130
131
132
133
134
135 public static <A> UnaryPredicate<A> predicate(UnaryPredicate<? super A> q, UnaryPredicate<? super A> r,
136 UnaryPredicate<? super A> s) {
137 return new ConditionalUnaryPredicate<A>(q, r, s);
138 }
139
140
141
142
143
144
145
146 public static <L, R> BinaryProcedure<L, R> procedure(BinaryPredicate<? super L, ? super R> q,
147 BinaryProcedure<? super L, ? super R> r) {
148 return new ConditionalBinaryProcedure<L, R>(q, r);
149 }
150
151
152
153
154
155
156
157
158 public static <L, R> BinaryProcedure<L, R> procedure(BinaryPredicate<? super L, ? super R> q,
159 BinaryProcedure<? super L, ? super R> r, BinaryProcedure<? super L, ? super R> s) {
160 return new ConditionalBinaryProcedure<L, R>(q, r, s);
161 }
162
163
164
165
166
167
168
169
170 public static <L, R, T> BinaryFunction<L, R, T> function(BinaryPredicate<? super L, ? super R> q,
171 BinaryFunction<? super L, ? super R, ? extends T> r, BinaryFunction<? super L, ? super R, ? extends T> s) {
172 return new ConditionalBinaryFunction<L, R, T>(q, r, s);
173 }
174
175
176
177
178
179
180
181
182 public static <L, R> BinaryPredicate<L, R> predicate(BinaryPredicate<? super L, ? super R> q,
183 BinaryPredicate<? super L, ? super R> r, BinaryPredicate<? super L, ? super R> s) {
184 return new ConditionalBinaryPredicate<L, R>(q, r, s);
185 }
186
187 }