View Javadoc
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  
11  package org.eclipse.jgit.internal.storage.dfs;
12  
13  /**
14   * A description of a Git repository on a DFS.
15   */
16  public class DfsRepositoryDescription {
17  	private final String repositoryName;
18  
19  	/**
20  	 * Initialize a new, empty repository description.
21  	 */
22  	public DfsRepositoryDescription() {
23  		this(null);
24  	}
25  
26  	/**
27  	 * Initialize a new repository description.
28  	 *
29  	 * @param repositoryName
30  	 *             the name of the repository.
31  	 */
32  	public DfsRepositoryDescription(String repositoryName) {
33  		this.repositoryName = repositoryName;
34  	}
35  
36  	/**
37  	 * Get the name of the repository.
38  	 *
39  	 * @return the name of the repository.
40  	 */
41  	public String getRepositoryName() {
42  		return repositoryName;
43  	}
44  
45  	/** {@inheritDoc} */
46  	@Override
47  	public int hashCode() {
48  		if (getRepositoryName() != null)
49  			return getRepositoryName().hashCode();
50  		return System.identityHashCode(this);
51  	}
52  
53  	/** {@inheritDoc} */
54  	@Override
55  	public boolean equals(Object b) {
56  		if (b instanceof DfsRepositoryDescription){
57  			String name = getRepositoryName();
58  			String otherName = ((DfsRepositoryDescription) b).getRepositoryName();
59  			return name != null ? name.equals(otherName) : this == b;
60  		}
61  		return false;
62  	}
63  
64  	/** {@inheritDoc} */
65  	@SuppressWarnings("nls")
66  	@Override
67  	public String toString() {
68  		return "DfsRepositoryDescription[" + getRepositoryName() + "]";
69  	}
70  }