@@ -446,7 +446,9 @@ public LifecycleRule(LifecycleAction action, LifecycleCondition condition) {
|
446 | 446 | && condition.getDaysSinceNoncurrentTime() == null
|
447 | 447 | && condition.getNoncurrentTimeBefore() == null
|
448 | 448 | && condition.getCustomTimeBefore() == null
|
449 |
| -&& condition.getDaysSinceCustomTime() == null) { |
| 449 | +&& condition.getDaysSinceCustomTime() == null |
| 450 | +&& condition.getMatchesPrefix() == null |
| 451 | +&& condition.getMatchesSuffix() == null) { |
450 | 452 | log.warning(
|
451 | 453 | "Creating a lifecycle condition with no supported conditions:\n"
|
452 | 454 | + this
|
@@ -527,7 +529,9 @@ Rule toPb() {
|
527 | 529 | lifecycleCondition.getCustomTimeBefore() == null
|
528 | 530 | ? null
|
529 | 531 | : new DateTime(true, lifecycleCondition.getCustomTimeBefore().getValue(), 0))
|
530 |
| -.setDaysSinceCustomTime(lifecycleCondition.getDaysSinceCustomTime()); |
| 532 | +.setDaysSinceCustomTime(lifecycleCondition.getDaysSinceCustomTime()) |
| 533 | +.setMatchesPrefix(lifecycleCondition.getMatchesPrefix()) |
| 534 | +.setMatchesSuffix(lifecycleCondition.getMatchesSuffix()); |
531 | 535 |
|
532 | 536 | rule.setCondition(condition);
|
533 | 537 |
|
@@ -604,6 +608,8 @@ public static class LifecycleCondition implements Serializable {
|
604 | 608 | private final DateTime noncurrentTimeBefore;
|
605 | 609 | private final DateTime customTimeBefore;
|
606 | 610 | private final Integer daysSinceCustomTime;
|
| 611 | +private final List<String> matchesPrefix; |
| 612 | +private final List<String> matchesSuffix; |
607 | 613 |
|
608 | 614 | private LifecycleCondition(Builder builder) {
|
609 | 615 | this.age = builder.age;
|
@@ -615,6 +621,8 @@ private LifecycleCondition(Builder builder) {
|
615 | 621 | this.noncurrentTimeBefore = builder.noncurrentTimeBefore;
|
616 | 622 | this.customTimeBefore = builder.customTimeBefore;
|
617 | 623 | this.daysSinceCustomTime = builder.daysSinceCustomTime;
|
| 624 | +this.matchesPrefix = builder.matchesPrefix; |
| 625 | +this.matchesSuffix = builder.matchesSuffix; |
618 | 626 | }
|
619 | 627 |
|
620 | 628 | public Builder toBuilder() {
|
@@ -627,7 +635,9 @@ public Builder toBuilder() {
|
627 | 635 | .setDaysSinceNoncurrentTime(this.daysSinceNoncurrentTime)
|
628 | 636 | .setNoncurrentTimeBefore(this.noncurrentTimeBefore)
|
629 | 637 | .setCustomTimeBefore(this.customTimeBefore)
|
630 |
| -.setDaysSinceCustomTime(this.daysSinceCustomTime); |
| 638 | +.setDaysSinceCustomTime(this.daysSinceCustomTime) |
| 639 | +.setMatchesPrefix(this.matchesPrefix) |
| 640 | +.setMatchesSuffix(this.matchesSuffix); |
631 | 641 | }
|
632 | 642 |
|
633 | 643 | public static Builder newBuilder() {
|
@@ -646,6 +656,8 @@ public String toString() {
|
646 | 656 | .add("noncurrentTimeBefore", noncurrentTimeBefore)
|
647 | 657 | .add("customTimeBefore", customTimeBefore)
|
648 | 658 | .add("daysSinceCustomTime", daysSinceCustomTime)
|
| 659 | +.add("matchesPrefix", matchesPrefix) |
| 660 | +.add("matchesSuffix", matchesSuffix) |
649 | 661 | .toString();
|
650 | 662 | }
|
651 | 663 |
|
@@ -691,6 +703,14 @@ public Integer getDaysSinceCustomTime() {
|
691 | 703 | return daysSinceCustomTime;
|
692 | 704 | }
|
693 | 705 |
|
| 706 | +public List<String> getMatchesPrefix() { |
| 707 | +return matchesPrefix; |
| 708 | +} |
| 709 | + |
| 710 | +public List<String> getMatchesSuffix() { |
| 711 | +return matchesSuffix; |
| 712 | +} |
| 713 | + |
694 | 714 | /** Builder for {@code LifecycleCondition}. */
|
695 | 715 | public static class Builder {
|
696 | 716 | private Integer age;
|
@@ -702,6 +722,8 @@ public static class Builder {
|
702 | 722 | private DateTime noncurrentTimeBefore;
|
703 | 723 | private DateTime customTimeBefore;
|
704 | 724 | private Integer daysSinceCustomTime;
|
| 725 | +private List<String> matchesPrefix; |
| 726 | +private List<String> matchesSuffix; |
705 | 727 |
|
706 | 728 | private Builder() {}
|
707 | 729 |
|
@@ -800,6 +822,24 @@ public Builder setDaysSinceCustomTime(Integer daysSinceCustomTime) {
|
800 | 822 | return this;
|
801 | 823 | }
|
802 | 824 |
|
| 825 | +/** |
| 826 | +* Sets the list of prefixes. If any prefix matches the beginning of the object’s name, this |
| 827 | +* portion of the condition is satisfied for that object. |
| 828 | +*/ |
| 829 | +public Builder setMatchesPrefix(List<String> matchesPrefix) { |
| 830 | +this.matchesPrefix = matchesPrefix != null ? ImmutableList.copyOf(matchesPrefix) : null; |
| 831 | +return this; |
| 832 | +} |
| 833 | + |
| 834 | +/** |
| 835 | +* Sets the list of suffixes. If any suffix matches the end of the object’s name, this |
| 836 | +* portion of the condition is satisfied for that object. |
| 837 | +*/ |
| 838 | +public Builder setMatchesSuffix(List<String> matchesSuffix) { |
| 839 | +this.matchesSuffix = matchesSuffix != null ? ImmutableList.copyOf(matchesSuffix) : null; |
| 840 | +return this; |
| 841 | +} |
| 842 | + |
803 | 843 | /** Builds a {@code LifecycleCondition} object. * */
|
804 | 844 | public LifecycleCondition build() {
|
805 | 845 | return new LifecycleCondition(this);
|
|
0 commit comments