|
5 | 5 | import java.time.LocalDate; |
6 | 6 | import java.time.LocalDateTime; |
7 | 7 | import java.time.LocalTime; |
| 8 | +import java.util.Arrays; |
| 9 | +import java.util.Collections; |
| 10 | +import java.util.List; |
8 | 11 | import java.util.Objects; |
9 | 12 | import java.util.function.Consumer; |
10 | 13 | import java.util.function.Function; |
@@ -299,4 +302,237 @@ public static <PROPERTY> AliasExpression<PROPERTY> alias( |
299 | 302 | Objects.requireNonNull(alias); |
300 | 303 | return new AliasExpression<>(propertyMetamodel, alias); |
301 | 304 | } |
| 305 | + |
| 306 | + /** |
| 307 | + * Creates a user-defined expression with the specified class and block. |
| 308 | + * |
| 309 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 310 | + * |
| 311 | + * @param <PROPERTY> type of expression result |
| 312 | + * @param klass the class of PROPERTY |
| 313 | + * @param name the name that must be unique among user-defined column expressions |
| 314 | + * @param operands the operand list used in the expression |
| 315 | + * @param block the SQL builder |
| 316 | + * @return user defined expression |
| 317 | + */ |
| 318 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 319 | + Class<PROPERTY> klass, |
| 320 | + String name, |
| 321 | + PropertyMetamodel<?>[] operands, |
| 322 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 323 | + Objects.requireNonNull(klass); |
| 324 | + Objects.requireNonNull(block); |
| 325 | + return userDefined(klass, name, Arrays.asList(operands), block); |
| 326 | + } |
| 327 | + |
| 328 | + /** |
| 329 | + * Creates a user-defined expression with the specified class and block. |
| 330 | + * |
| 331 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 332 | + * |
| 333 | + * @param <PROPERTY> type of expression result |
| 334 | + * @param klass the class of PROPERTY |
| 335 | + * @param name the name that must be unique among user-defined column expressions |
| 336 | + * @param operand the operand used in the expression |
| 337 | + * @param block the SQL builder |
| 338 | + * @return user defined expression |
| 339 | + */ |
| 340 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 341 | + Class<PROPERTY> klass, |
| 342 | + String name, |
| 343 | + PropertyMetamodel<?> operand, |
| 344 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 345 | + Objects.requireNonNull(klass); |
| 346 | + Objects.requireNonNull(block); |
| 347 | + return userDefined(klass, name, Collections.singletonList(operand), block); |
| 348 | + } |
| 349 | + |
| 350 | + /** |
| 351 | + * Creates a user-defined expression with the specified class and block. |
| 352 | + * |
| 353 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 354 | + * |
| 355 | + * @param <PROPERTY> type of expression result |
| 356 | + * @param klass the class of PROPERTY |
| 357 | + * @param name the name that must be unique among user-defined column expressions |
| 358 | + * @param operand1 the operand used in the expression |
| 359 | + * @param operand2 the operand used in the expression |
| 360 | + * @param block the SQL builder |
| 361 | + * @return user defined expression |
| 362 | + */ |
| 363 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 364 | + Class<PROPERTY> klass, |
| 365 | + String name, |
| 366 | + PropertyMetamodel<?> operand1, |
| 367 | + PropertyMetamodel<?> operand2, |
| 368 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 369 | + Objects.requireNonNull(klass); |
| 370 | + Objects.requireNonNull(block); |
| 371 | + return userDefined(klass, name, Arrays.asList(operand1, operand2), block); |
| 372 | + } |
| 373 | + |
| 374 | + /** |
| 375 | + * Creates a user-defined expression with the specified class and block. |
| 376 | + * |
| 377 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 378 | + * |
| 379 | + * @param <PROPERTY> type of expression result |
| 380 | + * @param klass the class of PROPERTY |
| 381 | + * @param name the name that must be unique among user-defined column expressions |
| 382 | + * @param operand1 the operand used in the expression |
| 383 | + * @param operand2 the operand used in the expression |
| 384 | + * @param operand3 the operand used in the expression |
| 385 | + * @param block the SQL builder |
| 386 | + * @return user defined expression |
| 387 | + */ |
| 388 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 389 | + Class<PROPERTY> klass, |
| 390 | + String name, |
| 391 | + PropertyMetamodel<?> operand1, |
| 392 | + PropertyMetamodel<?> operand2, |
| 393 | + PropertyMetamodel<?> operand3, |
| 394 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 395 | + Objects.requireNonNull(klass); |
| 396 | + Objects.requireNonNull(block); |
| 397 | + return userDefined(klass, name, Arrays.asList(operand1, operand2, operand3), block); |
| 398 | + } |
| 399 | + |
| 400 | + /** |
| 401 | + * Creates a user-defined expression with the specified class and block. |
| 402 | + * |
| 403 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 404 | + * |
| 405 | + * @param <PROPERTY> type of expression result |
| 406 | + * @param klass the class of PROPERTY |
| 407 | + * @param name the name that must be unique among user-defined column expressions |
| 408 | + * @param operands the operand list used in the expression |
| 409 | + * @param block the SQL builder |
| 410 | + * @return user defined expression |
| 411 | + */ |
| 412 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 413 | + Class<PROPERTY> klass, |
| 414 | + String name, |
| 415 | + List<? extends PropertyMetamodel<?>> operands, |
| 416 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 417 | + Objects.requireNonNull(klass); |
| 418 | + Objects.requireNonNull(block); |
| 419 | + return new UserDefinedExpression<>(klass, name, operands, block); |
| 420 | + } |
| 421 | + |
| 422 | + /** |
| 423 | + * Creates a user-defined expression with the specified resultPropertyMetamodel and block. |
| 424 | + * |
| 425 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 426 | + * |
| 427 | + * @param <PROPERTY> type of expression result |
| 428 | + * @param resultPropertyMetamodel the property metamodel of PROPERTY |
| 429 | + * @param name the name that must be unique among user-defined column expressions |
| 430 | + * @param operands the operand list used in the expression |
| 431 | + * @param block the SQL builder |
| 432 | + * @return user defined expression |
| 433 | + */ |
| 434 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 435 | + PropertyMetamodel<PROPERTY> resultPropertyMetamodel, |
| 436 | + String name, |
| 437 | + PropertyMetamodel<?>[] operands, |
| 438 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 439 | + Objects.requireNonNull(resultPropertyMetamodel); |
| 440 | + Objects.requireNonNull(block); |
| 441 | + return userDefined(resultPropertyMetamodel, name, Arrays.asList(operands), block); |
| 442 | + } |
| 443 | + |
| 444 | + /** |
| 445 | + * Creates a user-defined expression with the specified resultPropertyMetamodel and block. |
| 446 | + * |
| 447 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 448 | + * |
| 449 | + * @param <PROPERTY> type of expression result |
| 450 | + * @param resultPropertyMetamodel the property metamodel of PROPERTY |
| 451 | + * @param name the name that must be unique among user-defined column expressions |
| 452 | + * @param operand the operand used in the expression |
| 453 | + * @param block the SQL builder |
| 454 | + * @return user defined expression |
| 455 | + */ |
| 456 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 457 | + PropertyMetamodel<PROPERTY> resultPropertyMetamodel, |
| 458 | + String name, |
| 459 | + PropertyMetamodel<?> operand, |
| 460 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 461 | + Objects.requireNonNull(resultPropertyMetamodel); |
| 462 | + Objects.requireNonNull(block); |
| 463 | + return userDefined(resultPropertyMetamodel, name, Collections.singletonList(operand), block); |
| 464 | + } |
| 465 | + |
| 466 | + /** |
| 467 | + * Creates a user-defined expression with the specified resultPropertyMetamodel and block. |
| 468 | + * |
| 469 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 470 | + * |
| 471 | + * @param <PROPERTY> type of expression result |
| 472 | + * @param resultPropertyMetamodel the property metamodel of PROPERTY |
| 473 | + * @param name the name that must be unique among user-defined column expressions |
| 474 | + * @param operand1 the operand used in the expression |
| 475 | + * @param operand2 the operand used in the expression |
| 476 | + * @param block the SQL builder |
| 477 | + * @return user defined expression |
| 478 | + */ |
| 479 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 480 | + PropertyMetamodel<PROPERTY> resultPropertyMetamodel, |
| 481 | + String name, |
| 482 | + PropertyMetamodel<?> operand1, |
| 483 | + PropertyMetamodel<?> operand2, |
| 484 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 485 | + Objects.requireNonNull(resultPropertyMetamodel); |
| 486 | + Objects.requireNonNull(block); |
| 487 | + return userDefined(resultPropertyMetamodel, name, Arrays.asList(operand1, operand2), block); |
| 488 | + } |
| 489 | + |
| 490 | + /** |
| 491 | + * Creates a user-defined expression with the specified resultPropertyMetamodel and block. |
| 492 | + * |
| 493 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 494 | + * |
| 495 | + * @param <PROPERTY> type of expression result |
| 496 | + * @param resultPropertyMetamodel the property metamodel of PROPERTY |
| 497 | + * @param name the name that must be unique among user-defined column expressions |
| 498 | + * @param operand1 the operand used in the expression |
| 499 | + * @param operand2 the operand used in the expression |
| 500 | + * @param operand3 the operand used in the expression |
| 501 | + * @param block the SQL builder |
| 502 | + * @return user defined expression |
| 503 | + */ |
| 504 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 505 | + PropertyMetamodel<PROPERTY> resultPropertyMetamodel, |
| 506 | + String name, |
| 507 | + PropertyMetamodel<?> operand1, |
| 508 | + PropertyMetamodel<?> operand2, |
| 509 | + PropertyMetamodel<?> operand3, |
| 510 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 511 | + Objects.requireNonNull(resultPropertyMetamodel); |
| 512 | + Objects.requireNonNull(block); |
| 513 | + return userDefined( |
| 514 | + resultPropertyMetamodel, name, Arrays.asList(operand1, operand2, operand3), block); |
| 515 | + } |
| 516 | + |
| 517 | + /** |
| 518 | + * Creates a user-defined expression with the specified resultPropertyMetamodel and block. |
| 519 | + * |
| 520 | + * <p>The klass and name operands are used to determine identity of the expression. |
| 521 | + * |
| 522 | + * @param <PROPERTY> type of expression result |
| 523 | + * @param resultPropertyMetamodel the property metamodel of PROPERTY |
| 524 | + * @param name the name that must be unique among user-defined column expressions |
| 525 | + * @param operands the operand list used in the expression |
| 526 | + * @param block the SQL builder |
| 527 | + * @return user defined expression |
| 528 | + */ |
| 529 | + public static <PROPERTY> UserDefinedExpression<PROPERTY> userDefined( |
| 530 | + PropertyMetamodel<PROPERTY> resultPropertyMetamodel, |
| 531 | + String name, |
| 532 | + List<? extends PropertyMetamodel<?>> operands, |
| 533 | + Consumer<UserDefinedExpression.Declaration> block) { |
| 534 | + Objects.requireNonNull(resultPropertyMetamodel); |
| 535 | + Objects.requireNonNull(block); |
| 536 | + return new UserDefinedExpression<>(resultPropertyMetamodel, name, operands, block); |
| 537 | + } |
302 | 538 | } |
0 commit comments