001package co.codewizards.cloudstore.core.repo.local;
002
003import static java.util.Objects.*;
004
005import java.util.EventObject;
006
007import co.codewizards.cloudstore.core.context.ExtensibleContext;
008
009public class LocalRepoTransactionPostCloseEvent extends EventObject {
010        private static final long serialVersionUID = 1L;
011
012        private final LocalRepoManager localRepoManager;
013
014        public LocalRepoTransactionPostCloseEvent(LocalRepoTransaction source) {
015                super(source);
016                localRepoManager = requireNonNull(source, "source").getLocalRepoManager();
017        }
018
019        @Override
020        public LocalRepoTransaction getSource() {
021                return (LocalRepoTransaction) super.getSource();
022        }
023
024        /**
025         * Gets the <b>closed</b> {@link LocalRepoTransaction}.
026         * <p>
027         * Please note that this event is fired after the transaction was already closed. This object thus
028         * cannot be used for anything else than accessing its
029         * {@linkplain ExtensibleContext#getContextObject(Class) context-objects}.
030         * <p>
031         * Alternatively, you might want to access the {@link #getLocalRepoManager() localRepoManager}
032         * and create a new transaction.
033         * @return the <b>closed</b> {@link LocalRepoTransaction}. Never <code>null</code>.
034         */
035        public LocalRepoTransaction getTransaction() {
036                return getSource();
037        }
038
039        /**
040         * Gets the {@code LocalRepoManager}.
041         * @return the {@code LocalRepoManager}. Never <code>null</code>.
042         */
043        public LocalRepoManager getLocalRepoManager() {
044                return localRepoManager;
045        }
046}