DfsRepositoryDescription.java

  1. /*
  2.  * Copyright (C) 2011, 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. /**
  12.  * A description of a Git repository on a DFS.
  13.  */
  14. public class DfsRepositoryDescription {
  15.     private final String repositoryName;

  16.     /**
  17.      * Initialize a new, empty repository description.
  18.      */
  19.     public DfsRepositoryDescription() {
  20.         this(null);
  21.     }

  22.     /**
  23.      * Initialize a new repository description.
  24.      *
  25.      * @param repositoryName
  26.      *             the name of the repository.
  27.      */
  28.     public DfsRepositoryDescription(String repositoryName) {
  29.         this.repositoryName = repositoryName;
  30.     }

  31.     /**
  32.      * Get the name of the repository.
  33.      *
  34.      * @return the name of the repository.
  35.      */
  36.     public String getRepositoryName() {
  37.         return repositoryName;
  38.     }

  39.     /** {@inheritDoc} */
  40.     @Override
  41.     public int hashCode() {
  42.         if (getRepositoryName() != null)
  43.             return getRepositoryName().hashCode();
  44.         return System.identityHashCode(this);
  45.     }

  46.     /** {@inheritDoc} */
  47.     @Override
  48.     public boolean equals(Object b) {
  49.         if (b instanceof DfsRepositoryDescription){
  50.             String name = getRepositoryName();
  51.             String otherName = ((DfsRepositoryDescription) b).getRepositoryName();
  52.             return name != null ? name.equals(otherName) : this == b;
  53.         }
  54.         return false;
  55.     }

  56.     /** {@inheritDoc} */
  57.     @SuppressWarnings("nls")
  58.     @Override
  59.     public String toString() {
  60.         return "DfsRepositoryDescription[" + getRepositoryName() + "]";
  61.     }
  62. }