Fluent builder for a JsMetricType, obtained from an app's controllerMappings.newMetricTypeBuilder(). An app configures the id, title, calculation function and applicable entity types on the builder and calls build to register the metric type with the platform.
Group: Builders
Extends: AbstractFieldsBuilder
Properties
| Property | Returns | Description |
|---|---|---|
| applicableEntities | List<MetricEntity> | The applicable entity types set on this builder so far. |
| calcFn | String | The calculation function name configured on this builder so far. |
| description | String | The description configured on this builder so far. |
| fields | List<ExtraField> | The configurable fields set on this builder so far. |
| id | String | The metric type id configured on this builder so far. |
| title | String | The title configured on this builder so far. |
Methods
build() · id(String s) · additive(boolean b) · title(String s) · description(String s) · calcFn(String s) · fields(List<ExtraField> s) · applicableEntities(List<MetricEntity> s) · applicableToOrg() · applicableToProfile() · getId() · setId(String id) · getTitle() · setTitle(String title) · getFields() · setFields(List<ExtraField> fields) · getApplicableEntities() · setApplicableEntities(List<MetricEntity> applicableEntities) · getDescription() · setDescription(String description) · getCalcFn() · setCalcFn(String calcFn)
build()
Returns: JsMetricType
Builds the JsMetricType from the values configured on this builder, and registers it against the owning app's controller mapping list while the app is still initialising.
id(String s)
Returns: JsMetricTypeBuilder
Sets the unique identifier for the metric type, used elsewhere to reference it by metricTypeId.
| Parameter | Description |
|---|---|
s | the metric type id |
additive(boolean b)
Returns: JsMetricTypeBuilder
True (default) indicates that values for different periods can be added to give a total. False indicates that values cannot meaningfully be added, such as average values
| Parameter | Description |
|---|---|
b | true if values are additive across periods |
title(String s)
Returns: JsMetricTypeBuilder
Sets the display title of the metric type.
| Parameter | Description |
|---|---|
s | the title |
description(String s)
Returns: JsMetricTypeBuilder
Sets the descriptive text shown for metrics that use this metric type.
| Parameter | Description |
|---|---|
s | the description |
calcFn(String s)
Returns: JsMetricTypeBuilder
Sets the name of the JS function that calculates the metric value. The function is called with the rule parameters, the entity, the start and end dates and a CalcContext, and must return a numeric value.
| Parameter | Description |
|---|---|
s | the name of the calculation function |
fields(List<ExtraField> s)
Returns: JsMetricTypeBuilder
Sets the configurable fields that a metric using this metric type can be given values for, such as filter or grouping parameters.
| Parameter | Description |
|---|---|
s | the list of fields |
applicableEntities(List<MetricEntity> s)
Returns: JsMetricTypeBuilder
Sets which entity types (profile, org, or both) a metric using this metric type can apply to.
| Parameter | Description |
|---|---|
s | the list of applicable entity types |
applicableToOrg()
Returns: JsMetricTypeBuilder
Adds org to the list of entity types this metric type applies to.
applicableToProfile()
Returns: JsMetricTypeBuilder
Adds profile to the list of entity types this metric type applies to.
getId()
Returns: String
The metric type id configured on this builder so far.
setId(String id)
Returns: void
Sets the metric type id.
| Parameter | Description |
|---|---|
id | the metric type id |
getTitle()
Returns: String
The title configured on this builder so far.
setTitle(String title)
Returns: void
Sets the title.
| Parameter | Description |
|---|---|
title | the title |
getFields()
Returns: List<ExtraField>
The configurable fields set on this builder so far.
setFields(List<ExtraField> fields)
Returns: void
Sets the configurable fields.
| Parameter | Description |
|---|---|
fields | the list of fields |
getApplicableEntities()
Returns: List<MetricEntity>
The applicable entity types set on this builder so far.
setApplicableEntities(List<MetricEntity> applicableEntities)
Returns: void
Sets the applicable entity types.
| Parameter | Description |
|---|---|
applicableEntities | the list of applicable entity types |
getDescription()
Returns: String
The description configured on this builder so far.
setDescription(String description)
Returns: void
Sets the description.
| Parameter | Description |
|---|---|
description | the description |
getCalcFn()
Returns: String
The calculation function name configured on this builder so far.
setCalcFn(String calcFn)
Returns: void
Sets the name of the JS function that calculates the metric value.
| Parameter | Description |
|---|---|
calcFn | the name of the calculation function |