/**
  * Binary condition for Numeric greater than comparison. Supports both integral and floating point numeric types.
  *
  * @param variable      The JSONPath expression that determines which piece of the input document is used for the comparison.
  * @param expectedValue The expected value for this condition.
  * @return NumericGreaterThanOrEqualCondition.Builder
  * @see
  * <a href="https://states-language.net/spec.html#choice-state">https://states-language.net/spec.html#choice-state</a>
  * @see Choice
  */
 public static NumericGreaterThanOrEqualCondition <long> .Builder NumericGreaterThanEquals(string variable,
                                                                                           long expectedValue)
 {
     return(NumericGreaterThanOrEqualCondition <long> .GetBuilder()
            .Variable(variable).ExpectedValue(expectedValue));
 }
Beispiel #2
0
 /**
  * Binary condition for Numeric greater than comparison. Supports both integral and floating point numeric types.
  *
  * @param variable      The JSONPath expression that determines which piece of the input document is used for the comparison.
  * @param expectedValue The expected value for this condition.
  * @return NumericGreaterThanOrEqualCondition.Builder
  * @see <a href="https://states-language.net/spec.html#choice-state">https://states-language.net/spec.html#choice-state</a>
  * @see Choice
  */
 public static NumericGreaterThanOrEqualCondition <double> .Builder Gte(string variable, double expectedValue)
 {
     return((NumericGreaterThanOrEqualCondition <double> .Builder) NumericGreaterThanOrEqualCondition <double> .GetBuilder()
            .Variable(variable).ExpectedValue(expectedValue));
 }
        public IConditionBuilder<ICondition> DeserializeCondition(JObject node)
        {
            if (node.Property(PropertyNames.VARIABLE) != null)
            {
                if (node.Property(PropertyNames.STRING_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringEqualsCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_EQUALS_PATH) != null)
                {
                    return DeserializeBinaryPathCondition(StringEqualsPathCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_GREATER_THAN) != null)
                {
                    return DeserializeBinaryCondition(StringGreaterThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_GREATER_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringGreaterThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_LESS_THAN) != null)
                {
                    return DeserializeBinaryCondition(StringLessThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.STRING_LESS_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(StringLessThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_GREATER_THAN) != null)
                {
                    return DeserializeBinaryCondition(TimestampGreaterThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_GREATER_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampGreaterThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_LESS_THAN) != null)
                {
                    return DeserializeBinaryCondition(TimestampLessThanCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.TIMESTAMP_LESS_THAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(TimestampLessThanOrEqualCondition.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericEqualsCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericEqualsCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_GREATER_THAN) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_GREATER_THAN).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericGreaterThanCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericGreaterThanCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_GREATER_THAN_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_GREATER_THAN_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericGreaterThanOrEqualCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericGreaterThanOrEqualCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_LESS_THAN) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_LESS_THAN).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericLessThanCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericLessThanCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.NUMERIC_LESS_THAN_EQUALS) != null)
                {
                    if (node.Property(PropertyNames.NUMERIC_LESS_THAN_EQUALS).Value.Type == JTokenType.Integer)
                    {
                        return DeserializeBinaryCondition(NumericLessThanOrEqualCondition<long>.GetBuilder(), node);
                    }

                    return DeserializeBinaryCondition(NumericLessThanOrEqualCondition<decimal>.GetBuilder(), node);
                }

                if (node.Property(PropertyNames.BOOLEAN_EQUALS) != null)
                {
                    return DeserializeBinaryCondition(BooleanEqualsCondition.GetBuilder(), node);
                }
            }
            else if (node.Property(PropertyNames.AND) != null)
            {
                var builder = AndCondition.GetBuilder();
                foreach (var inner in node[PropertyNames.AND].Children())
                {
                    builder.Condition(DeserializeCondition((JObject) inner));
                }

                return builder;
            }
            else if (node.Property(PropertyNames.OR) != null)
            {
                var builder = OrCondition.GetBuilder();
                foreach (var inner in node[PropertyNames.OR].Children())
                {
                    builder.Condition(DeserializeCondition((JObject) inner));
                }

                return builder;
            }
            else if (node.Property(PropertyNames.NOT) != null)
            {
                return NotCondition.GetBuilder()
                    .Condition(DeserializeCondition((JObject) node.Property(PropertyNames.NOT).First));
            }

            throw new StatesLanguageException("Condition must be provided");
        }