CharacterHead.java

  1. /*
  2.  * Copyright (C) 2008, Florian Köberle <florianskarten@web.de> 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.fnmatch;

  11. final class CharacterHead extends AbstractHead {
  12.     private final char expectedCharacter;

  13.     /**
  14.      * Constructor for CharacterHead
  15.      *
  16.      * @param expectedCharacter
  17.      *            expected {@code char}
  18.      */
  19.     CharacterHead(char expectedCharacter) {
  20.         super(false);
  21.         this.expectedCharacter = expectedCharacter;
  22.     }

  23.     /** {@inheritDoc} */
  24.     @Override
  25.     protected final boolean matches(char c) {
  26.         return c == expectedCharacter;
  27.     }

  28.     /** {@inheritDoc} */
  29.     @Override
  30.     public String toString() {
  31.         return String.valueOf(expectedCharacter);
  32.     }

  33. }