using JetBrains.Annotations; namespace Abp.Specifications { public static class SpecificationExtensions { /// /// Combines the current specification instance with another specification instance /// and returns the combined specification which represents that both the current and /// the given specification must be satisfied by the given object. /// /// The specification /// The specification instance with which the current specification is combined. /// The combined specification instance. public static ISpecification And([NotNull] this ISpecification specification, [NotNull] ISpecification other) { Check.NotNull(specification, nameof(specification)); Check.NotNull(other, nameof(other)); return new AndSpecification(specification, other); } /// /// Combines the current specification instance with another specification instance /// and returns the combined specification which represents that either the current or /// the given specification should be satisfied by the given object. /// /// The specification /// The specification instance with which the current specification /// is combined. /// The combined specification instance. public static ISpecification Or([NotNull] this ISpecification specification, [NotNull] ISpecification other) { Check.NotNull(specification, nameof(specification)); Check.NotNull(other, nameof(other)); return new OrSpecification(specification, other); } /// /// Combines the current specification instance with another specification instance /// and returns the combined specification which represents that the current specification /// should be satisfied by the given object but the specified specification should not. /// /// The specification /// The specification instance with which the current specification /// is combined. /// The combined specification instance. public static ISpecification AndNot([NotNull] this ISpecification specification, [NotNull] ISpecification other) { Check.NotNull(specification, nameof(specification)); Check.NotNull(other, nameof(other)); return new AndNotSpecification(specification, other); } /// /// Reverses the current specification instance and returns a specification which represents /// the semantics opposite to the current specification. /// /// The reversed specification instance. public static ISpecification Not([NotNull] this ISpecification specification) { Check.NotNull(specification, nameof(specification)); return new NotSpecification(specification); } } }