Package velox.api.layer1.agreement
Class AgreementInfo.Builder
java.lang.Object
velox.api.layer1.agreement.AgreementInfo.Builder
- Enclosing class:
AgreementInfo
Builder for constructing
AgreementInfo instances.
Required fields: agreementId, agreementTitle, agreementText, and expirationDate.
Optional fields: acceptButtonText, declineButtonText, agreementComponents, and declineConfirmation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRadioButtonGroup(String id, String labelText, AgreementComponent.RadioButtonGroup.Option[] options) Convenience method to add radio button group as additional component to agreement dialog.build()Builds and returns a newAgreementInfoinstance from the values set on this builder.setAcceptButtonText(String acceptButtonText) Optional text for accept button.setAgreementComponents(List<AgreementComponent> agreementComponents) Additional components to be shown in agreement dialog, e.g.setAgreementId(String agreementId) Sets the unique identifier of the agreement.setAgreementText(String agreementText) The main text of the agreement.setAgreementTitle(String agreementTitle) Sets the title of the agreement dialog.setDeclineButtonText(String declineButtonText) Optional text for decline button.setDeclineConfirmation(AgreementDeclineConfirmationCallback declineConfirmation) Optional confirmation calback to be called when user clicks decline button.setExpirationDate(LocalDate expirationDate) Expiration date of agreement.
-
Constructor Details
-
Builder
public Builder()Creates a new empty builder.
-
-
Method Details
-
setAgreementId
Sets the unique identifier of the agreement.- Parameters:
agreementId- unique agreement identifier. SeeAgreementInfo.agreementIdfor naming conventions.- Returns:
- builder instance
-
setAgreementTitle
Sets the title of the agreement dialog.- Parameters:
agreementTitle- the title text to display in the agreement dialog- Returns:
- builder instance
-
setAgreementText
The main text of the agreement. Can be in a plain HTML format (e.g. use only the tags supported by JEditorPane). -
setAcceptButtonText
Optional text for accept button. If not set, default value "Accept" will be used.- Parameters:
acceptButtonText- text to be shown on accept button in agreement dialog. Can be null or empty, in that case default value "Accept" will be used.- Returns:
- builder instance
-
setDeclineButtonText
Optional text for decline button. If not set, default value "Decline" will be used.- Parameters:
declineButtonText- text to be shown on decline button in agreement dialog. Can be null or empty, in that case default value "Decline" will be used.- Returns:
- builder instance
-
setExpirationDate
Expiration date of agreement. If agreement is already accepted, but expiration date is in the past, agreement will be considered as expired and agreement will be requested to be accepted again.- Parameters:
expirationDate- expiration date of agreement. Cannot be null. Set far in the future if agreement does not expire.- Returns:
- builder instance
-
setAgreementComponents
Additional components to be shown in agreement dialog, e.g. radio buttons. They will be shown below agreement text and above accept/decline buttons.- Parameters:
agreementComponents- list of components to be shown in agreement dialog. Can be null or empty if no additional components are needed.- Returns:
- builder instance
-
addRadioButtonGroup
public AgreementInfo.Builder addRadioButtonGroup(String id, String labelText, AgreementComponent.RadioButtonGroup.Option[] options) Convenience method to add radio button group as additional component to agreement dialog. Added radio button group will be shown below agreement text and above accept/decline buttons. If there are already some components added, new radio button group will be added to the end of the list. If agreementComponents field is not set, it will be initialized with a new list.- Parameters:
id- seeAgreementComponent.RadioButtonGroup.id()labelText- seeAgreementComponent.RadioButtonGroup.labelText()options- seeAgreementComponent.RadioButtonGroup.options()- Returns:
- builder instance
- See Also:
-
setDeclineConfirmation
public AgreementInfo.Builder setDeclineConfirmation(AgreementDeclineConfirmationCallback declineConfirmation) Optional confirmation calback to be called when user clicks decline button. It can be used to show additional confirmation dialog when user wants to decline agreement. If the function returns true, the dialog will close, otherwise it will remain open and allow the user to accept the agreement. the function accept this dialog for the parameter as the parent for any additional dialog that may be shown. -
build
Builds and returns a newAgreementInfoinstance from the values set on this builder.- Returns:
- a new
AgreementInfoinstance - Throws:
IllegalStateException- if any required field (agreementId,agreementTitle,agreementText, orexpirationDate) is not set, or if agreement components contain duplicate ids
-