RestrictedWildCardHead.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 RestrictedWildCardHead extends AbstractHead {
  12.     private final char excludedCharacter;

  13.     RestrictedWildCardHead(char excludedCharacter, boolean star) {
  14.         super(star);
  15.         this.excludedCharacter = excludedCharacter;
  16.     }

  17.     /** {@inheritDoc} */
  18.     @Override
  19.     protected final boolean matches(char c) {
  20.         return c != excludedCharacter;
  21.     }

  22.     /** {@inheritDoc} */
  23.     @Override
  24.     public String toString() {
  25.         return isStar() ? "*" : "?"; //$NON-NLS-1$ //$NON-NLS-2$
  26.     }
  27. }