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.transactionlog;
011
012import jakarta.annotation.Nonnull;
013import org.apache.commons.lang3.Validate;
014
015import java.util.HashMap;
016
017/**
018 * This class is just a thin wrapper around a map of search parameters for Transaction Logs.
019 *
020 * Usage:
021 * TransactionLogSearch search = new TransactionLogSearch();
022 * search.addSearchParameter(SOURCE_TRANSACTION_ID, "abc-123");
023 *
024 */
025public class TransactionLogSearch extends HashMap<TransactionLogSearch.SearchKeyEnum, Object> {
026
027        @Override
028        public Object put(SearchKeyEnum theKey, Object theValue) {
029                Validate.notNull(theValue);
030                return super.put(theKey, theValue);
031        }
032
033        /**
034         * Method which just delegates to the put method, but is more descriptive for implementers.
035         */
036        public void addSearchParameter(SearchKeyEnum theParameter, @Nonnull Object theValue) {
037                this.put(theParameter, theValue);
038        }
039
040        public static TransactionLogSearch all() {
041                return new TransactionLogSearch();
042        }
043
044        public enum SearchKeyEnum {
045                /*
046                 * Sorting agnostic
047                 */
048
049                SOURCE_TRANSACTION_ID,
050                SOURCE_TRANSACTION_ENDPOINT,
051                TRANSACTION_USER,
052                TRANSACTION_EVENTTYPE,
053                TRANSACTION_EVENTSUBTYPE,
054                TRANSACTION_OUTCOME,
055                TRANSACTION_USER_PID,
056                TRANSACTION_URL
057        }
058}