001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.camel; 011 012import ca.cdr.api.model.json.TransactionLogStepJson; 013import org.apache.camel.Exchange; 014 015import java.util.List; 016 017/** 018 * Contract for Camel procedures which provide their own constructed list of transaction log steps 019 */ 020@FunctionalInterface 021public interface ITxLogStepsProvider { 022 023 /** 024 * Calls function which returns a list of transaction log steps from the passed {@code Exchange} 025 * @param theExchange the camel Exchange 026 * @return list of TransactionLogStepJson the steps built 027 */ 028 List<TransactionLogStepJson> provideTxLogSteps(Exchange theExchange); 029 030 /** 031 * Convenience method to provide the step which the returned provider will return in a list 032 * @param theStep the {@code TransactionLogStepJson} which will be returned in a list from the returned {@code ITransactionLogStepsProvider} 033 * @return a {@code ITransactionLogStepsProvider} which will return a singleton list with the received step 034 */ 035 static ITxLogStepsProvider ofStep(TransactionLogStepJson theStep) { 036 return (unusedExchange) -> List.of(theStep); 037 } 038 039 /** 040 * Convenience method to provide the steps which the returned provider will return 041 * @param theSteps the list of {@code TransactionLogStepJson} which will be returned in a list from the returned {@code ITransactionLogStepsProvider} 042 * @return a {@code ITransactionLogStepsProvider} which will return the received list of steps 043 */ 044 static ITxLogStepsProvider ofSteps(List<TransactionLogStepJson> theSteps) { 045 return (unusedExchange) -> theSteps; 046 } 047}