|
18 | 18 | import notion.api.v1.model.databases.query.filter.CompoundFilterElement;
|
19 | 19 | import notion.api.v1.model.databases.query.filter.QueryTopLevelFilter;
|
20 | 20 | import notion.api.v1.model.databases.query.filter.condition.CheckboxFilter;
|
| 21 | +import notion.api.v1.model.databases.query.filter.condition.FilesFilter; |
21 | 22 | import notion.api.v1.model.databases.query.filter.condition.MultiSelectFilter;
|
22 | 23 | import notion.api.v1.model.databases.query.filter.condition.NumberFilter;
|
23 | 24 | import notion.api.v1.model.databases.query.filter.condition.SelectFilter;
|
| 25 | +import notion.api.v1.model.databases.query.filter.condition.StatusFilter; |
24 | 26 |
|
25 | 27 | import java.util.ArrayList;
|
26 | 28 | import java.util.List;
|
@@ -310,6 +312,16 @@ public CheckboxCondition<T> checkbox(String property) {
|
310 | 312 | return new CheckboxCondition<>(property, factory);
|
311 | 313 | }
|
312 | 314 |
|
| 315 | + /** |
| 316 | + * Start the definition of the filter condition for a {@code files} property. |
| 317 | + * @param property The name of the property as it appears in the database, or the |
| 318 | + * property ID |
| 319 | + * @return a new {@link CheckboxCondition} instance |
| 320 | + */ |
| 321 | + public FilesCondition<T> files(String property) { |
| 322 | + return new FilesCondition<>(property, factory); |
| 323 | + } |
| 324 | + |
313 | 325 | /**
|
314 | 326 | * Start the definition of the filter condition for a {@code multi-select}
|
315 | 327 | * property.
|
@@ -341,6 +353,16 @@ public SelectCondition<T> select(String property) {
|
341 | 353 | return new SelectCondition<>(property, factory);
|
342 | 354 | }
|
343 | 355 |
|
| 356 | + /** |
| 357 | + * Start the definition of the filter condition for a {@code status} property. |
| 358 | + * @param property The name of the property as it appears in the database, or the |
| 359 | + * property ID |
| 360 | + * @return a new {@link StatusCondition} instance |
| 361 | + */ |
| 362 | + public StatusCondition<T> status(String property) { |
| 363 | + return new StatusCondition<>(property, factory); |
| 364 | + } |
| 365 | + |
344 | 366 | static abstract sealed class Condition<T extends Filter> {
|
345 | 367 |
|
346 | 368 | private final String property;
|
@@ -393,6 +415,39 @@ public T isNotEqualTo(boolean value) {
|
393 | 415 |
|
394 | 416 | }
|
395 | 417 |
|
| 418 | + /** |
| 419 | + * Filter condition for a {@code files} property. |
| 420 | + * |
| 421 | + * @param <T> the type of the target filter |
| 422 | + */ |
| 423 | + public static final class FilesCondition<T extends Filter> extends Condition<T> { |
| 424 | + |
| 425 | + private FilesCondition(String property, NotionPropertyFilterFactory<T> factory) { |
| 426 | + super(property, factory); |
| 427 | + } |
| 428 | + |
| 429 | + /** |
| 430 | + * Return database entries where the property value does not contain any data. |
| 431 | + * @return a filter with the newly defined condition |
| 432 | + */ |
| 433 | + public T isEmpty() { |
| 434 | + FilesFilter filesFilter = new FilesFilter(); |
| 435 | + filesFilter.setEmpty(true); |
| 436 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setFile(filesFilter)); |
| 437 | + } |
| 438 | + |
| 439 | + /** |
| 440 | + * Return database entries where the property value contains data. |
| 441 | + * @return a filter with the newly defined condition |
| 442 | + */ |
| 443 | + public T isNotEmpty() { |
| 444 | + FilesFilter filesFilter = new FilesFilter(); |
| 445 | + filesFilter.setNotEmpty(true); |
| 446 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setFile(filesFilter)); |
| 447 | + } |
| 448 | + |
| 449 | + } |
| 450 | + |
396 | 451 | /**
|
397 | 452 | * Filter condition for a {@code multi-select} property.
|
398 | 453 | *
|
@@ -610,6 +665,62 @@ public T isNotEmpty() {
|
610 | 665 |
|
611 | 666 | }
|
612 | 667 |
|
| 668 | + /** |
| 669 | + * Filter condition for a {@code status} property. |
| 670 | + * |
| 671 | + * @param <T> the type of the target filter |
| 672 | + */ |
| 673 | + public static final class StatusCondition<T extends Filter> extends Condition<T> { |
| 674 | + |
| 675 | + private StatusCondition(String property, NotionPropertyFilterFactory<T> factory) { |
| 676 | + super(property, factory); |
| 677 | + } |
| 678 | + |
| 679 | + /** |
| 680 | + * Return database entries where the property value matches the provided one. |
| 681 | + * @param value the value to compare the property value against |
| 682 | + * @return a filter with the newly defined condition |
| 683 | + */ |
| 684 | + public T isEqualTo(String value) { |
| 685 | + StatusFilter statusFilter = new StatusFilter(); |
| 686 | + statusFilter.setEquals(value); |
| 687 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setStatus(statusFilter)); |
| 688 | + } |
| 689 | + |
| 690 | + /** |
| 691 | + * Return database entries where the property value does not match the |
| 692 | + * provided one. |
| 693 | + * @param value the value to compare the property value against |
| 694 | + * @return a filter with the newly defined condition |
| 695 | + */ |
| 696 | + public T isNotEqualTo(String value) { |
| 697 | + StatusFilter statusFilter = new StatusFilter(); |
| 698 | + statusFilter.setDoesNotEqual(value); |
| 699 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setStatus(statusFilter)); |
| 700 | + } |
| 701 | + |
| 702 | + /** |
| 703 | + * Return database entries where the property value does not contain any data. |
| 704 | + * @return a filter with the newly defined condition |
| 705 | + */ |
| 706 | + public T isEmpty() { |
| 707 | + StatusFilter statusFilter = new StatusFilter(); |
| 708 | + statusFilter.setEmpty(true); |
| 709 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setStatus(statusFilter)); |
| 710 | + } |
| 711 | + |
| 712 | + /** |
| 713 | + * Return database entries where the property value contains data. |
| 714 | + * @return a filter with the newly defined condition |
| 715 | + */ |
| 716 | + public T isNotEmpty() { |
| 717 | + StatusFilter statusFilter = new StatusFilter(); |
| 718 | + statusFilter.setNotEmpty(true); |
| 719 | + return toFilter(notionPropertyFilter -> notionPropertyFilter.setStatus(statusFilter)); |
| 720 | + } |
| 721 | + |
| 722 | + } |
| 723 | + |
613 | 724 | }
|
614 | 725 |
|
615 | 726 | }
|
0 commit comments