BeforeDfsPackIndexLoadedEvent.java

  1. /*
  2.  * Copyright (C) 2012, Google Inc. and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.internal.storage.dfs;

  11. import org.eclipse.jgit.events.RepositoryEvent;

  12. /**
  13.  * Describes the {@link org.eclipse.jgit.internal.storage.dfs.DfsPackFile} just
  14.  * before its index is loaded. Currently, DfsPackFile directly dispatches the
  15.  * event on {@link org.eclipse.jgit.lib.Repository#getGlobalListenerList}. Which
  16.  * means the call to {@link #getRepository} will always return null.
  17.  */
  18. public class BeforeDfsPackIndexLoadedEvent
  19.         extends RepositoryEvent<BeforeDfsPackIndexLoadedListener> {
  20.     private final DfsPackFile pack;

  21.     /**
  22.      * A new event triggered before a PackFile index is loaded.
  23.      *
  24.      * @param pack
  25.      *            the pack
  26.      */
  27.     public BeforeDfsPackIndexLoadedEvent(DfsPackFile pack) {
  28.         this.pack = pack;
  29.     }

  30.     /**
  31.      * Get the PackFile containing the index that will be loaded.
  32.      *
  33.      * @return the PackFile containing the index that will be loaded.
  34.      */
  35.     public DfsPackFile getPackFile() {
  36.         return pack;
  37.     }

  38.     /** {@inheritDoc} */
  39.     @Override
  40.     public Class<BeforeDfsPackIndexLoadedListener> getListenerType() {
  41.         return BeforeDfsPackIndexLoadedListener.class;
  42.     }

  43.     /** {@inheritDoc} */
  44.     @Override
  45.     public void dispatch(BeforeDfsPackIndexLoadedListener listener) {
  46.         listener.onBeforeDfsPackIndexLoaded(this);
  47.     }
  48. }