Class SalesStreamDistributionBuilder

java.lang.Object
org.kigalisim.engine.support.ValidatedBuilder<SalesStreamDistribution>
org.kigalisim.engine.recalc.SalesStreamDistributionBuilder

public class SalesStreamDistributionBuilder extends ValidatedBuilder<SalesStreamDistribution>
Builder for creating sales stream distribution percentages.

This class implements the logic for determining the appropriate percentage split between import, domestic, and export based on which streams have been explicitly enabled and their current values.

  • Constructor Details

    • SalesStreamDistributionBuilder

      public SalesStreamDistributionBuilder()
      Create builder without any values initialized.
  • Method Details

    • setDomesticSales

      public SalesStreamDistributionBuilder setDomesticSales(EngineNumber domesticSales)
      Set the domestic sales value.
      Parameters:
      domesticSales - Current domestic sales value
      Returns:
      This builder for method chaining
    • setImportSales

      public SalesStreamDistributionBuilder setImportSales(EngineNumber importSales)
      Set the import sales value.
      Parameters:
      importSales - Current import sales value
      Returns:
      This builder for method chaining
    • setDomesticEnabled

      public SalesStreamDistributionBuilder setDomesticEnabled(boolean domesticEnabled)
      Set whether domestic stream is enabled.
      Parameters:
      domesticEnabled - true if domestic stream has ever been enabled
      Returns:
      This builder for method chaining
    • setImportEnabled

      public SalesStreamDistributionBuilder setImportEnabled(boolean importEnabled)
      Set whether import stream is enabled.
      Parameters:
      importEnabled - true if import stream has ever been enabled
      Returns:
      This builder for method chaining
    • setExportSales

      public SalesStreamDistributionBuilder setExportSales(EngineNumber exportSales)
      Set the export sales value.
      Parameters:
      exportSales - Current export sales value
      Returns:
      This builder for method chaining
    • setExportEnabled

      public SalesStreamDistributionBuilder setExportEnabled(boolean exportEnabled)
      Set whether export stream is enabled.
      Parameters:
      exportEnabled - true if export stream has ever been enabled
      Returns:
      This builder for method chaining
    • setIncludeExports

      public SalesStreamDistributionBuilder setIncludeExports(boolean includeExports)
      Set whether exports should be included in the distribution.
      Parameters:
      includeExports - true if exports should be included in distribution calculations
      Returns:
      This builder for method chaining
    • buildInternal

      protected SalesStreamDistribution buildInternal()
      Build a sales stream distribution based on provided values.
      Distribution logic:
      • If exports are excluded: 100% split between import and domestic only
      • If exports are included: proportional split between import, domestic, and export
      • Proportional split based on current values if streams have sales
      • Equal split among enabled streams if no current sales
      Specified by:
      buildInternal in class ValidatedBuilder<SalesStreamDistribution>
      Returns:
      A SalesStreamDistribution with appropriate percentages
    • validate

      protected void validate()
      Check that all required fields are set before construction.
      Specified by:
      validate in class ValidatedBuilder<SalesStreamDistribution>
      Throws:
      IllegalStateException - if any required field is missing