FooterKey.java

  1. /*
  2.  * Copyright (C) 2009, 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.revwalk;

  11. import java.util.Locale;

  12. import org.eclipse.jgit.lib.Constants;

  13. /**
  14.  * Case insensitive key for a {@link org.eclipse.jgit.revwalk.FooterLine}.
  15.  */
  16. public final class FooterKey {
  17.     /** Standard {@code Signed-off-by} */
  18.     public static final FooterKey SIGNED_OFF_BY = new FooterKey("Signed-off-by"); //$NON-NLS-1$

  19.     /** Standard {@code Acked-by} */
  20.     public static final FooterKey ACKED_BY = new FooterKey("Acked-by"); //$NON-NLS-1$

  21.     /** Standard {@code CC} */
  22.     public static final FooterKey CC = new FooterKey("CC"); //$NON-NLS-1$

  23.     private final String name;

  24.     final byte[] raw;

  25.     /**
  26.      * Create a key for a specific footer line.
  27.      *
  28.      * @param keyName
  29.      *            name of the footer line.
  30.      */
  31.     public FooterKey(String keyName) {
  32.         name = keyName;
  33.         raw = Constants.encode(keyName.toLowerCase(Locale.ROOT));
  34.     }

  35.     /**
  36.      * Get name of this footer line.
  37.      *
  38.      * @return name of this footer line.
  39.      */
  40.     public String getName() {
  41.         return name;
  42.     }

  43.     /** {@inheritDoc} */
  44.     @SuppressWarnings("nls")
  45.     @Override
  46.     public String toString() {
  47.         return "FooterKey[" + name + "]";
  48.     }
  49. }