1 //////////////////////////////////////////////////////////////////////////////// 2 // checkstyle: Checks Java source code for adherence to a set of rules. 3 // Copyright (C) 2001-2019 the original author or authors. 4 // 5 // This library is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU Lesser General Public 7 // License as published by the Free Software Foundation; either 8 // version 2.1 of the License, or (at your option) any later version. 9 // 10 // This library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public 16 // License along with this library; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 //////////////////////////////////////////////////////////////////////////////// 19 20 package com.puppycrawl.tools.checkstyle.checks.naming; 21 22 import com.puppycrawl.tools.checkstyle.api.DetailAST; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 25 /** 26 * <p> 27 * Abstract class for checking if a class/method type parameter's name 28 * conforms to a format specified by the format property. 29 * </p> 30 * 31 * <p>This class extends {@link AbstractNameCheck}</p> 32 * @deprecated Checkstyle will not support abstract checks anymore. Use 33 * {@link AbstractNameCheck} instead. 34 * @noinspection AbstractClassNeverImplemented 35 */ 36 @Deprecated 37 public abstract class AbstractTypeParameterNameCheck 38 extends AbstractNameCheck { 39 40 /** 41 * Creates a new {@code AbstractTypeParameterNameCheck} instance. 42 * @param format format to check with 43 */ 44 protected AbstractTypeParameterNameCheck(String format) { 45 super(format); 46 } 47 48 /** 49 * This method must be overridden to specify the 50 * location of the type parameter to check. 51 * 52 * @return {@code TokenTypes.CLASS_DEF } 53 * or {@code TokenTypes.METHOD_DEF } 54 */ 55 protected abstract int getLocation(); 56 57 @Override 58 public final int[] getDefaultTokens() { 59 return new int[] { 60 TokenTypes.TYPE_PARAMETER, 61 }; 62 } 63 64 @Override 65 public final int[] getAcceptableTokens() { 66 return new int[] { 67 TokenTypes.TYPE_PARAMETER, 68 }; 69 } 70 71 @Override 72 protected final boolean mustCheckName(DetailAST ast) { 73 final DetailAST location = 74 ast.getParent().getParent(); 75 return location.getType() == getLocation(); 76 } 77 78 }