Class AbstractComposer<C extends Candidate,​I extends AdvancedComposition<C>,​R extends Result>

    • Constructor Detail

      • AbstractComposer

        public AbstractComposer​(I composition,
                                java.util.function.Function<? super I,​R> assembleResult)
        Parameters:
        composition - the composition to manage
        assembleResult - a method to assemble the result from the candidate collection
    • Method Detail

      • accept

        public void accept​(C candidate)
        Delegates the decision on whether to accept a candidate to deliberateAcceptance().
        Specified by:
        accept in interface Composer<C extends Candidate,​I extends AdvancedComposition<C>,​R extends Result>
        Specified by:
        accept in interface java.util.function.Consumer<C extends Candidate>
        Parameters:
        candidate - the candidate to be handled
      • composition

        protected I composition()
      • deliberateAcceptance

        protected abstract boolean deliberateAcceptance​(C candidate)
        Hook method where the acceptance decision is made.
        Parameters:
        candidate - the candidate to decide acceptance for
        Returns:
        whether to accept this candidate
      • acceptCandidate

        protected final void acceptCandidate​(C candidate)
      • rejectCandidate

        protected final void rejectCandidate​(C candidate)
      • revokeAcceptance

        protected final void revokeAcceptance​(C candidate)
      • revokeLastAcceptance

        protected final void revokeLastAcceptance()
      • acceptanceRevoked

        protected abstract void acceptanceRevoked​(C candidate)
        Hook for actions to perform on initially accepted candidates which are now removed.
        Parameters:
        candidate - the revoked candidate
      • candidateAccepted

        protected abstract void candidateAccepted​(C candidate)
        Hook for actions to perform on accepted candidates.
        Parameters:
        candidate - the accepted candidate
      • candidateRejected

        protected abstract void candidateRejected​(C candidate)
        Hook for actions to perform on rejected candidates.
        Parameters:
        candidate - the rejected candidate
      • isFinished

        public boolean isFinished()
        Description copied from interface: Composer
        Whether this composer has reached a state where it does not want to handle new candidates.
        Specified by:
        isFinished in interface Composer<C extends Candidate,​I extends AdvancedComposition<C>,​R extends Result>
        Returns:
        true iff no more candidates will be accepted
      • getIntermediateResult

        public final I getIntermediateResult()
        Description copied from interface: Composer
        Typically just returns the internally managed composition. Care must be taken, that this method may be called asynchronously.
        Specified by:
        getIntermediateResult in interface Composer<C extends Candidate,​I extends AdvancedComposition<C>,​R extends Result>
        Returns:
        the intermediate result
      • generateResult

        public final R generateResult()
        Description copied from interface: Composer
        Hook method where a final result is computed from the incrementally built up intermediate result.
        Specified by:
        generateResult in interface Composer<C extends Candidate,​I extends AdvancedComposition<C>,​R extends Result>
        Returns:
        the final result