001 package fj; 002 003 import static fj.FW.$; 004 005 /** 006 * A product-6. 007 * 008 * @version %build.number%<br> 009 * <ul> 010 * <li>$LastChangedRevision: 270 $</li> 011 * <li>$LastChangedDate: 2009-07-28 14:06:27 +1000 (Tue, 28 Jul 2009) $</li> 012 * </ul> 013 */ 014 @SuppressWarnings({"UnnecessaryFullyQualifiedName"}) 015 public abstract class P6<A, B, C, D, E, F> { 016 /** 017 * Access the first element of the product. 018 * 019 * @return The first element of the product. 020 */ 021 public abstract A _1(); 022 023 /** 024 * Access the second element of the product. 025 * 026 * @return The second element of the product. 027 */ 028 public abstract B _2(); 029 030 /** 031 * Access the third element of the product. 032 * 033 * @return The third element of the product. 034 */ 035 public abstract C _3(); 036 037 /** 038 * Access the fourth element of the product. 039 * 040 * @return The fourth element of the product. 041 */ 042 public abstract D _4(); 043 044 /** 045 * Access the fifth element of the product. 046 * 047 * @return The fifth element of the product. 048 */ 049 public abstract E _5(); 050 051 /** 052 * Access the sixth element of the product. 053 * 054 * @return The sixth element of the product. 055 */ 056 public abstract F _6(); 057 058 /** 059 * Map the first element of the product. 060 * 061 * @param f The function to map with. 062 * @return A product with the given function applied. 063 */ 064 public <X> P6<X, B, C, D, E, F> map1(final fj.F<A, X> f) { 065 return new P6<X, B, C, D, E, F>() { 066 public X _1() { 067 return f.f(P6.this._1()); 068 } 069 070 public B _2() { 071 return P6.this._2(); 072 } 073 074 public C _3() { 075 return P6.this._3(); 076 } 077 078 public D _4() { 079 return P6.this._4(); 080 } 081 082 public E _5() { 083 return P6.this._5(); 084 } 085 086 public F _6() { 087 return P6.this._6(); 088 } 089 }; 090 } 091 092 /** 093 * Map the second element of the product. 094 * 095 * @param f The function to map with. 096 * @return A product with the given function applied. 097 */ 098 public <X> P6<A, X, C, D, E, F> map2(final fj.F<B, X> f) { 099 return new P6<A, X, C, D, E, F>() { 100 public A _1() { 101 return P6.this._1(); 102 } 103 104 public X _2() { 105 return f.f(P6.this._2()); 106 } 107 108 public C _3() { 109 return P6.this._3(); 110 } 111 112 public D _4() { 113 return P6.this._4(); 114 } 115 116 public E _5() { 117 return P6.this._5(); 118 } 119 120 public F _6() { 121 return P6.this._6(); 122 } 123 }; 124 } 125 126 /** 127 * Map the third element of the product. 128 * 129 * @param f The function to map with. 130 * @return A product with the given function applied. 131 */ 132 public <X> P6<A, B, X, D, E, F> map3(final fj.F<C, X> f) { 133 return new P6<A, B, X, D, E, F>() { 134 public A _1() { 135 return P6.this._1(); 136 } 137 138 public B _2() { 139 return P6.this._2(); 140 } 141 142 public X _3() { 143 return f.f(P6.this._3()); 144 } 145 146 public D _4() { 147 return P6.this._4(); 148 } 149 150 public E _5() { 151 return P6.this._5(); 152 } 153 154 public F _6() { 155 return P6.this._6(); 156 } 157 }; 158 } 159 160 /** 161 * Map the fourth element of the product. 162 * 163 * @param f The function to map with. 164 * @return A product with the given function applied. 165 */ 166 public <X> P6<A, B, C, X, E, F> map4(final fj.F<D, X> f) { 167 return new P6<A, B, C, X, E, F>() { 168 public A _1() { 169 return P6.this._1(); 170 } 171 172 public B _2() { 173 return P6.this._2(); 174 } 175 176 public C _3() { 177 return P6.this._3(); 178 } 179 180 public X _4() { 181 return f.f(P6.this._4()); 182 } 183 184 public E _5() { 185 return P6.this._5(); 186 } 187 188 public F _6() { 189 return P6.this._6(); 190 } 191 }; 192 } 193 194 /** 195 * Map the fifth element of the product. 196 * 197 * @param f The function to map with. 198 * @return A product with the given function applied. 199 */ 200 public <X> P6<A, B, C, D, X, F> map5(final fj.F<E, X> f) { 201 return new P6<A, B, C, D, X, F>() { 202 public A _1() { 203 return P6.this._1(); 204 } 205 206 public B _2() { 207 return P6.this._2(); 208 } 209 210 public C _3() { 211 return P6.this._3(); 212 } 213 214 public D _4() { 215 return P6.this._4(); 216 } 217 218 public X _5() { 219 return f.f(P6.this._5()); 220 } 221 222 public F _6() { 223 return P6.this._6(); 224 } 225 }; 226 } 227 228 /** 229 * Map the sixth element of the product. 230 * 231 * @param f The function to map with. 232 * @return A product with the given function applied. 233 */ 234 public <X> P6<A, B, C, D, E, X> map6(final fj.F<F, X> f) { 235 return new P6<A, B, C, D, E, X>() { 236 public A _1() { 237 return P6.this._1(); 238 } 239 240 public B _2() { 241 return P6.this._2(); 242 } 243 244 public C _3() { 245 return P6.this._3(); 246 } 247 248 public D _4() { 249 return P6.this._4(); 250 } 251 252 public E _5() { 253 return P6.this._5(); 254 } 255 256 public X _6() { 257 return f.f(P6.this._6()); 258 } 259 }; 260 } 261 262 /** 263 * Returns the 1-product projection over the first element. 264 * 265 * @return the 1-product projection over the first element. 266 */ 267 public P1<A> _1_() { 268 return $(P6.<A, B, C, D, E, F>__1()).lazy().f(this); 269 } 270 271 /** 272 * Returns the 1-product projection over the second element. 273 * 274 * @return the 1-product projection over the second element. 275 */ 276 public P1<B> _2_() { 277 return $(P6.<A, B, C, D, E, F>__2()).lazy().f(this); 278 } 279 280 /** 281 * Returns the 1-product projection over the third element. 282 * 283 * @return the 1-product projection over the third element. 284 */ 285 public P1<C> _3_() { 286 return $(P6.<A, B, C, D, E, F>__3()).lazy().f(this); 287 } 288 289 /** 290 * Returns the 1-product projection over the fourth element. 291 * 292 * @return the 1-product projection over the fourth element. 293 */ 294 public P1<D> _4_() { 295 return $(P6.<A, B, C, D, E, F>__4()).lazy().f(this); 296 } 297 298 /** 299 * Returns the 1-product projection over the fifth element. 300 * 301 * @return the 1-product projection over the fifth element. 302 */ 303 public P1<E> _5_() { 304 return $(P6.<A, B, C, D, E, F>__5()).lazy().f(this); 305 } 306 307 /** 308 * Returns the 1-product projection over the sixth element. 309 * 310 * @return the 1-product projection over the sixth element. 311 */ 312 public P1<F> _6_() { 313 return $(P6.<A, B, C, D, E, F>__6()).lazy().f(this); 314 } 315 316 /** 317 * Provides a memoising P6 that remembers its values. 318 * 319 * @return A P6 that calls this P6 once for any given element and remembers the value for subsequent calls. 320 */ 321 public P6<A, B, C, D, E, F> memo() { 322 return new P6<A, B, C, D, E, F>() { 323 private final P1<A> a = _1_().memo(); 324 private final P1<B> b = _2_().memo(); 325 private final P1<C> c = _3_().memo(); 326 private final P1<D> d = _4_().memo(); 327 private final P1<E> e = _5_().memo(); 328 private final P1<F> f = _6_().memo(); 329 330 public A _1() { 331 return a._1(); 332 } 333 334 public B _2() { 335 return b._1(); 336 } 337 338 public C _3() { 339 return c._1(); 340 } 341 342 public D _4() { 343 return d._1(); 344 } 345 346 public E _5() { 347 return e._1(); 348 } 349 350 public F _6() { 351 return f._1(); 352 } 353 }; 354 } 355 356 357 /** 358 * Returns a function that returns the first element of a product. 359 * 360 * @return A function that returns the first element of a product. 361 */ 362 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, A> __1() { 363 return new fj.F<P6<A, B, C, D, E, F$>, A>() { 364 public A f(final P6<A, B, C, D, E, F$> p) { 365 return p._1(); 366 } 367 }; 368 } 369 370 /** 371 * Returns a function that returns the second element of a product. 372 * 373 * @return A function that returns the second element of a product. 374 */ 375 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, B> __2() { 376 return new fj.F<P6<A, B, C, D, E, F$>, B>() { 377 public B f(final P6<A, B, C, D, E, F$> p) { 378 return p._2(); 379 } 380 }; 381 } 382 383 /** 384 * Returns a function that returns the third element of a product. 385 * 386 * @return A function that returns the third element of a product. 387 */ 388 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, C> __3() { 389 return new fj.F<P6<A, B, C, D, E, F$>, C>() { 390 public C f(final P6<A, B, C, D, E, F$> p) { 391 return p._3(); 392 } 393 }; 394 } 395 396 /** 397 * Returns a function that returns the fourth element of a product. 398 * 399 * @return A function that returns the fourth element of a product. 400 */ 401 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, D> __4() { 402 return new fj.F<P6<A, B, C, D, E, F$>, D>() { 403 public D f(final P6<A, B, C, D, E, F$> p) { 404 return p._4(); 405 } 406 }; 407 } 408 409 /** 410 * Returns a function that returns the fifth element of a product. 411 * 412 * @return A function that returns the fifth element of a product. 413 */ 414 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, E> __5() { 415 return new fj.F<P6<A, B, C, D, E, F$>, E>() { 416 public E f(final P6<A, B, C, D, E, F$> p) { 417 return p._5(); 418 } 419 }; 420 } 421 422 /** 423 * Returns a function that returns the sixth element of a product. 424 * 425 * @return A function that returns the sixth element of a product. 426 */ 427 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, F$> __6() { 428 return new fj.F<P6<A, B, C, D, E, F$>, F$>() { 429 public F$ f(final P6<A, B, C, D, E, F$> p) { 430 return p._6(); 431 } 432 }; 433 } 434 }