chore: initial git load of code space
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
namespace Strata.SqlTools.Rules.Rule.Expression;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an ANY expression that checks if any element in a collection satisfies a condition.
|
||||
/// </summary>
|
||||
public class Any : BoolExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection property being evaluated.
|
||||
/// </summary>
|
||||
public CollectionProperty CollectionProperty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BoolExpr expression that defines the condition to check.
|
||||
/// </summary>
|
||||
public BoolExpr BoolExpr { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter used in the predicate expression.
|
||||
/// </summary>
|
||||
public Parameter PredicateParameter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Any"/> class with a function.
|
||||
/// </summary>
|
||||
/// <param name="collectionProperty">The collection property to evaluate.</param>
|
||||
/// <param name="func">A function that defines the condition to check for each element.</param>
|
||||
public Any(CollectionProperty collectionProperty, Func<Parameter, BoolExpr> func)
|
||||
{
|
||||
CollectionProperty = collectionProperty;
|
||||
PredicateParameter = new Parameter("p");
|
||||
BoolExpr = func(PredicateParameter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Any"/> class with a BoolExpr expression.
|
||||
/// </summary>
|
||||
/// <param name="collectionProperty">The collection property to evaluate.</param>
|
||||
/// <param name="boolExpr">The BoolExpr expression defining the condition.</param>
|
||||
public Any(CollectionProperty collectionProperty, BoolExpr boolExpr)
|
||||
: this(collectionProperty, boolExpr, new Parameter("p"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Any"/> class.
|
||||
/// </summary>
|
||||
/// <param name="collectionProperty">The collection property to evaluate.</param>
|
||||
/// <param name="boolExpr">The BoolExpr expression defining the condition.</param>
|
||||
/// <param name="predicateParameter">The parameter used in the predicate expression.</param>
|
||||
public Any(CollectionProperty collectionProperty, BoolExpr boolExpr, Parameter predicateParameter)
|
||||
{
|
||||
CollectionProperty = collectionProperty;
|
||||
BoolExpr = boolExpr;
|
||||
PredicateParameter = predicateParameter;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override T Accept<T>(IVisitor<T> visitor) => visitor.VisitAny(this);
|
||||
}
|
||||
Reference in New Issue
Block a user