Sha1CollisionException.java

  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. package org.eclipse.jgit.util.sha1;

  11. import java.text.MessageFormat;

  12. import org.eclipse.jgit.internal.JGitText;
  13. import org.eclipse.jgit.lib.ObjectId;

  14. /**
  15.  * Thrown by {@link org.eclipse.jgit.util.sha1.SHA1Java} if it detects a likely hash
  16.  * collision.
  17.  *
  18.  * @since 4.7
  19.  */
  20. public class Sha1CollisionException extends RuntimeException {
  21.     private static final long serialVersionUID = 1L;

  22.     /**
  23.      * Initialize with default message.
  24.      *
  25.      * @param id
  26.      *            object whose contents are a hash collision.
  27.      */
  28.     public Sha1CollisionException(ObjectId id) {
  29.         super(MessageFormat.format(
  30.                 JGitText.get().sha1CollisionDetected,
  31.                 id.name()));
  32.     }
  33. }