001//////////////////////////////////////////////////////////////////////////////// 002// checkstyle: Checks Java source code for adherence to a set of rules. 003// Copyright (C) 2001-2015 the original author or authors. 004// 005// This library is free software; you can redistribute it and/or 006// modify it under the terms of the GNU Lesser General Public 007// License as published by the Free Software Foundation; either 008// version 2.1 of the License, or (at your option) any later version. 009// 010// This library is distributed in the hope that it will be useful, 011// but WITHOUT ANY WARRANTY; without even the implied warranty of 012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013// Lesser General Public License for more details. 014// 015// You should have received a copy of the GNU Lesser General Public 016// License along with this library; if not, write to the Free Software 017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 018//////////////////////////////////////////////////////////////////////////////// 019 020package com.puppycrawl.tools.checkstyle.checks.naming; 021 022import com.puppycrawl.tools.checkstyle.api.TokenTypes; 023 024/** 025 * <p> 026 * Checks that interface type parameter names conform to a format specified 027 * by the format property. The format is a 028 * {@link java.util.regex.Pattern regular expression} and defaults to 029 * <strong>^[A-Z]$</strong>. 030 * </p> 031 * <p> 032 * An example of how to configure the check is: 033 * </p> 034 * <pre> 035 * <module name="InterfaceTypeParameterName"/> 036 * </pre> 037 * <p> 038 * An example of how to configure the check for names that are only a single 039 * letter is 040 * </p> 041 * <pre> 042 * <module name="InterfaceTypeParameterName"> 043 * <property name="format" value="^[a-zA-Z]$"/> 044 * </module> 045 * </pre> 046 * 047 * @author maxvetrenko 048 */ 049public class InterfaceTypeParameterNameCheck 050 extends AbstractTypeParameterNameCheck { 051 /** Creates a new {@code InterfaceTypeParameterNameCheck} instance. */ 052 public InterfaceTypeParameterNameCheck() { 053 super("^[A-Z]$"); 054 } 055 056 @Override 057 public int[] getRequiredTokens() { 058 return new int[] {TokenTypes.TYPE_PARAMETER}; 059 } 060 061 @Override 062 protected final int getLocation() { 063 return TokenTypes.INTERFACE_DEF; 064 } 065}