View Javadoc
1   /*
2    * Copyright (C) 2017, 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.util.sha1;
12  
13  import java.text.MessageFormat;
14  
15  import org.eclipse.jgit.internal.JGitText;
16  import org.eclipse.jgit.lib.ObjectId;
17  
18  /**
19   * Thrown by {@link org.eclipse.jgit.util.sha1.SHA1} if it detects a likely hash
20   * collision.
21   *
22   * @since 4.7
23   */
24  public class Sha1CollisionException extends RuntimeException {
25  	private static final long serialVersionUID = 1L;
26  
27  	/**
28  	 * Initialize with default message.
29  	 *
30  	 * @param id
31  	 *            object whose contents are a hash collision.
32  	 */
33  	public Sha1CollisionException(ObjectId id) {
34  		super(MessageFormat.format(
35  				JGitText.get().sha1CollisionDetected,
36  				id.name()));
37  	}
38  }