Fluent builder for constructing and persisting a new promotion (a Reward). Configure the desired fields with the setter methods, then call build to save the promotion together with its group and organisation filters. Obtained from PromotionsManager.newPromotionBuilder; every setter returns this builder so calls can be chained.
Group: Builders
Methods
group(Group g) · startDate(Date s) · endDate(Date s) · promoStatus(String s) · itemImage(String name, String hash) · promoStatusActive() · includedOrgType(OrgType g) · excludedOrgType(OrgType g) · includedOrg(Organisation g) · subTitle(String subTitle) · client(Organisation client) · featured(boolean featured) · category(RewardCategory category) · url(String url) · groupRequirements(String groupRequirements) · build()
group(Group g)
Returns: PromotionBuilder
Adds a group to the list of groups the built promotion will be filtered by.
| Parameter | Description |
|---|---|
g | the group to add |
startDate(Date s)
Returns: PromotionBuilder
Sets the date the promotion opens.
| Parameter | Description |
|---|---|
s | the start date |
endDate(Date s)
Returns: PromotionBuilder
Sets the date the promotion closes.
| Parameter | Description |
|---|---|
s | the end date |
promoStatus(String s)
Returns: PromotionBuilder
Sets the status the built promotion will be created with, for example Reward.STATUS_ACTIVE.
| Parameter | Description |
|---|---|
s | the status value |
itemImage(String name, String hash)
Returns: PromotionBuilder
Sets the item image for the promotion. Both name and hash must be non-null for the image to be applied.
| Parameter | Description |
|---|---|
name | the file name of the image |
hash | the content hash of the already-stored image file |
promoStatusActive()
Returns: PromotionBuilder
Sets the promotion status to Reward.STATUS_ACTIVE.
includedOrgType(OrgType g)
Returns: PromotionBuilder
Restricts the promotion to organisations of the given type.
| Parameter | Description |
|---|---|
g | the organisation type to include |
excludedOrgType(OrgType g)
Returns: PromotionBuilder
Excludes organisations of the given type from the promotion.
| Parameter | Description |
|---|---|
g | the organisation type to exclude |
includedOrg(Organisation g)
Returns: PromotionBuilder
Restricts the promotion to the given organisation, added as an inclusive participant selector.
| Parameter | Description |
|---|---|
g | the organisation to include |
subTitle(String subTitle)
Returns: PromotionBuilder
Sets the promotion's subtitle, applied only if it is non-blank.
| Parameter | Description |
|---|---|
subTitle | the subtitle text |
client(Organisation client)
Returns: PromotionBuilder
Sets the client organisation the promotion is created for.
| Parameter | Description |
|---|---|
client | the client organisation |
featured(boolean featured)
Returns: PromotionBuilder
Sets whether the promotion is flagged as featured.
| Parameter | Description |
|---|---|
featured | true to feature the promotion |
category(RewardCategory category)
Returns: PromotionBuilder
Sets the reward category the promotion belongs to.
| Parameter | Description |
|---|---|
category | the reward category |
url(String url)
Returns: PromotionBuilder
Sets the promotion's url.
| Parameter | Description |
|---|---|
url | the promotion url |
groupRequirements(String groupRequirements)
Returns: PromotionBuilder
Sets how the promotion's group filters combine. Only "and" is currently supported; any other non-blank value causes build to throw an IllegalArgumentException.
| Parameter | Description |
|---|---|
groupRequirements | the group combination mode, or null for the default (or) behaviour |
build()
Returns: Reward
Validates and persists the configured promotion: creates the Reward, applies its image, points org type filters, client, featured flag, category, url, group requirements and participant selectors, then attaches any configured groups.