Ejemplo n.º 1
0
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="name">Decision table name</param>
        /// <param name="hitPolicy">Decision table hit policy</param>
        /// <param name="aggregation">Aggregation type of Collect hit policy</param>
        /// <param name="inputs">Decision table inputs</param>
        /// <param name="outputs">Decision table outputs</param>
        /// <param name="rules">Decision table rules</param>
        /// <param name="requiredInputs">Inputs the decision table depends on.</param>
        /// <param name="requiredDecisions">Decisions that needs to be evaluated before the decision table (provide the inputs to the table).</param>
        /// <exception cref="ArgumentNullException"><paramref name="inputs"/>, <paramref name="outputs"/> or <paramref name="rules"/> is null</exception>
        /// <exception cref="ArgumentException"><paramref name="inputs"/>, <paramref name="outputs"/> or <paramref name="rules"/> is empty</exception>
        public DmnDecisionTable(
            string name,
            HitPolicyEnum hitPolicy, CollectHitPolicyAggregationEnum aggregation,
            DmnDecisionTableInput[] inputs,
            DmnDecisionTableOutput[] outputs,
            DmnDecisionTableRule[] rules,
            IReadOnlyCollection <IDmnVariable> requiredInputs,
            IReadOnlyCollection <IDmnDecision> requiredDecisions)
            : base(name, requiredInputs, requiredDecisions)
        {
            HitPolicy   = hitPolicy;
            Aggregation = aggregation;
            Inputs      = inputs ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(inputs)} is null");
            Outputs     = outputs ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(outputs)} is null");
            Rules       = rules ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(rules)} is null");

            if (inputs.Length < 1)
            {
                throw Logger.Fatal <ArgumentException>("No inputs for the table");
            }
            if (outputs.Length < 1)
            {
                throw Logger.Fatal <ArgumentException>("No outputs for the table");
            }
            if (rules.Length < 1)
            {
                throw Logger.Fatal <ArgumentException>("No rules for the table");
            }
        }
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="name">Decision table name</param>
        /// <param name="hitPolicy">Decision table hit policy</param>
        /// <param name="aggregation">Aggregation type of Collect hit policy</param>
        /// <param name="inputs">Decision table inputs</param>
        /// <param name="outputs">Decision table outputs</param>
        /// <param name="rules">Decision table rules</param>
        /// <param name="requiredInputs">Inputs the decision table depends on.</param>
        /// <param name="requiredDecisions">Decisions that needs to be evaluated before the decision table (provide the inputs to the table).</param>
        /// <exception cref="ArgumentNullException"><paramref name="inputs"/>, <paramref name="outputs"/> or <paramref name="rules"/> is null</exception>
        /// <exception cref="ArgumentException"><paramref name="inputs"/>, <paramref name="outputs"/> or <paramref name="rules"/> is empty</exception>
        public DmnDecisionTable(
            string name,
            HitPolicyEnum hitPolicy, CollectHitPolicyAggregationEnum aggregation,
            List <DmnDecisionTableInput> inputs,
            List <DmnDecisionTableOutput> outputs,
            List <DmnDecisionTableRule> rules,
            List <DmnVariableDefinition> requiredInputs, List <IDmnDecision> requiredDecisions)
            : base(name, requiredInputs, requiredDecisions)
        {
            HitPolicy   = hitPolicy;
            Aggregation = aggregation;
            Inputs      = inputs ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(inputs)} is null");
            Outputs     = outputs ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(outputs)} is null");
            Rules       = rules ?? throw Logger.Fatal <ArgumentNullException>($"{nameof(rules)} is null");

            if (inputs.Count < 1)
            {
                throw Logger.Fatal <ArgumentException>("No inputs for the table");
            }
            if (outputs.Count < 1)
            {
                throw Logger.Fatal <ArgumentException>("No outputs for the table");
            }
            if (rules.Count < 1)
            {
                throw Logger.Fatal <ArgumentException>("No rules for the table");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the hit policy of the decision table
 /// </summary>
 /// <param name="hitPolicy">Decision table hit policy</param>
 /// <exception cref="DmnBuilderException">Throws <see cref="DmnBuilderException"/> when the definition has already been built</exception>
 public TableDecision WithHitPolicy(HitPolicyEnum hitPolicy)
 {
     if (IsBuilt)
     {
         throw Logger.Error <DmnBuilderException>($"Decision is already built");
     }
     HitPolicy = hitPolicy;
     return(this);
 }