Calculator

The Calculator element allows you to dynamically choose the number and type of buckets for a PreDefinedMixedBucketization TLV.

For example: Using fixed values, a Timeline can be requested as 14 days, then 8 split weeks, then 3 months. But using TimelineCalculator, you can automatically create more complex combinations such as 2 weeks of days, followed by 2 months of split weeks, followed by 3 months. The precise number of buckets may depend on how many days are let in the current week/etc, giving a much more flexible and user-friendly bucketization scheme.

You can specify a Calculator in the TLV as follows.

<PreDefinedMixedBucketization>
<Bucketization>DAILY</Bucketization>
<Bucketization>SPLIT_WEEK</Bucketization>
<Bucketization>MONTHLY</Bucketization>
<Calculator class="com.example.TestCalculator">
<Param name="WEEKS_OF_DAYS" value="2"/>
<Param name="MONTHS_OF_SPLIT_WEEK" value="2"/>
<Param name="MONTHS" value="3"/>
</Calculator>
</PreDefinedMixedBucketization>

The value of the "class" attribute should be the fully-qualified name of a class implementing com.onenetwork.platform.data.tlv.TimelineCalculator. You may optionally nest multiple "Parameter" elements within this to further control the behavior of the calculator. (It is up to the implementation to decide what Parameter names it supports, and what it will do with those Parameters.)

public interface TimelineCalculator {
void calculate(TimelineBuilder builder, Map<String, String> params);
}