UNPKG

@type-ddd/patterns

Version:

This package provide utils file and interfaces to assistant build a complex application with domain driving design

47 lines (46 loc) 1.86 kB
export interface ISpecification<T> { isSatisfiedBy: (target: T) => boolean; and: (other: ISpecification<T>) => ISpecification<T>; or: (other: ISpecification<T>) => ISpecification<T>; andNot: (other: ISpecification<T>) => ISpecification<T>; orNot: (other: ISpecification<T>) => ISpecification<T>; not: () => ISpecification<T>; } export declare abstract class Specification<T> implements ISpecification<T> { abstract isSatisfiedBy(target: T): boolean; and(other: ISpecification<T>): ISpecification<T>; or(other: ISpecification<T>): ISpecification<T>; orNot(other: ISpecification<T>): ISpecification<T>; andNot(other: ISpecification<T>): ISpecification<T>; not(): ISpecification<T>; } export declare class AndSpecification<T> extends Specification<T> { private readonly one; private readonly other; constructor(one: ISpecification<T>, other: ISpecification<T>); isSatisfiedBy(target: T): boolean; } export declare class OrSpecification<T> extends Specification<T> { private readonly one; private readonly other; constructor(one: ISpecification<T>, other: ISpecification<T>); isSatisfiedBy(target: T): boolean; } export declare class OrNotSpecification<T> extends Specification<T> { private readonly one; private readonly other; constructor(one: ISpecification<T>, other: ISpecification<T>); isSatisfiedBy(target: T): boolean; } export declare class AndNotSpecification<T> extends Specification<T> { private readonly one; private readonly other; constructor(one: ISpecification<T>, other: ISpecification<T>); isSatisfiedBy(target: T): boolean; } export declare class NotSpecification<T> extends Specification<T> { private readonly other; constructor(other: ISpecification<T>); isSatisfiedBy(target: T): boolean; } export default Specification;