Class IdentitySpecification<A extends AggregateRoot<I>,​I>

  • Type Parameters:
    A - the aggregate type this specification applies to.
    I - the aggregate identifier type.
    All Implemented Interfaces:
    Specification<A>

    public class IdentitySpecification<A extends AggregateRoot<I>,​I>
    extends Object
    implements Specification<A>
    A specification that can only be applied to AggregateRoots and that is satisfied only if the candidate aggregate has an identifier equal to the expected one.
    • Constructor Detail

      • IdentitySpecification

        public IdentitySpecification​(I expectedIdentifier)
        Creates a specification satisfied only if the candidate aggregate has an identifier equal to the identifier passed as argument.
        Parameters:
        expectedIdentifier - the expected identifier.
    • Method Detail

      • isSatisfiedBy

        public boolean isSatisfiedBy​(A candidate)
        Description copied from interface: Specification
        Evaluates if the candidate object passed as argument satisfies the specification.
        Specified by:
        isSatisfiedBy in interface Specification<A extends AggregateRoot<I>>
        Parameters:
        candidate - the candidate object to check.
        Returns:
        true if the candidate object satisfies the specification, false otherwise.
      • getExpectedIdentifier

        public I getExpectedIdentifier()
        Returns the identifier that is expected.
        Returns:
        the expected identifier.