Fluent Commerce Logo
Docs
Sign In

Rule Structure

Topic

Author:

Fluent Commerce

Changed on:

6 Nov 2023

Overview

Rules are written using Java, and contain a specific structure and metadata for describing and validating the . Rules are designed to be building blocks for logic, and typically produce a single outcome or . The Rules SDK also provides a number of built-in dependencies for implementing Rules, including working with and other Utilities.

Rule Definition

Author:

Fluent Commerce

Changed on:

6 Nov 2023

Overview

Basic structure of a Framework

Key points

  • A Workflow framework rule includes a Java class, and additional event and parameters. 
  • The rule's annotation needs to follow best practises. More details here.

The basic structure of a Framework includes:

  • A Java Class implementing the `com.fluentretail.rubix.v2.rule.Rule` interface
  • `@RuleInfo` Annotation describing the metadata for the Rule
  • Additional Event and Parameter Annotations defining the inputs of the Rule

Here's an example of a simple :

1package com.example.rule;
2
3import com.fluentretail.rubix.rule.meta.RuleInfo;
4import com.fluentretail.rubix.v2.context.Context;
5import com.fluentretail.rubix.v2.rule.Rule;
6
7@RuleInfo(
8        name = "ExampleRule"
9        , description = "This is the description of the Example Rule, which should include all parameters declared below like this: {ParamString1}"
10)
11@ParamString(name = "ParamString1", description = "Parameter String 1", defaultValue = "PS1")
12@EventAttribute(name = "EventAttribute1", type = "STRING")
13public class ExampleRule implements Rule {
14
15    @Override
16    public <C extends Context> void run(C context) {
17        // ...
18    }
19}

See the following references for more on Structure:

Fluent Commerce

Fluent Commerce