Skip to content

Commit

Permalink
Merge pull request #223 from ncautotest/docs-filter-with
Browse files Browse the repository at this point in the history
add example of filterWith(FilterBy)
  • Loading branch information
nhirrle authored Oct 26, 2023
2 parents c5bce3e + 615e260 commit 487135a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,26 @@ aecu.contentUpgradeBuilder()
.run()
```

#### Filter with custom FilterBy implementation

To filter by complex conditions that are not covered by existing `filterBy...()` presets you can use `filterWith()` that takes a custom `FilterBy` implementation as shown in the example below:

```java
aecu.contentUpgradeBuilder()
.forDescendantResourcesOf("/content/we-retail/ca/en", false)
.filterWith(new FilterBy(){
public boolean filter(Resource resource, StringBuilder output) {
ValueMap properties = resource.valueMap
Calendar lastModified = properties.get("cq:lastModified", Calendar.class)
Calendar cal = Calendar.instance
cal.add(Calendar.YEAR, -5)
return lastModified.time.before(cal.time)
}
})
.doSetProperty("old", true) // mark pages that weren't modified in the past 5 years
.run()
```

<a name="binding_execute"></a>

### Execute Options
Expand Down

0 comments on commit 487135a

Please sign in to comment.