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 class 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 * &lt;module name="ClassTypeParameterName"/&gt;
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 * &lt;module name="ClassTypeParameterName"&gt;
043 *    &lt;property name="format" value="^[a-zA-Z]$"/&gt;
044 * &lt;/module&gt;
045 * </pre>
046 *
047 * @author Travis Schneeberger
048 */
049public class ClassTypeParameterNameCheck
050    extends AbstractTypeParameterNameCheck {
051    /** Creates a new {@code ClassTypeParameterNameCheck} instance. */
052    public ClassTypeParameterNameCheck() {
053        super("^[A-Z]$");
054    }
055
056    @Override
057    public int[] getRequiredTokens() {
058        return new int[] {
059            TokenTypes.TYPE_PARAMETER,
060        };
061    }
062
063    @Override
064    protected final int getLocation() {
065        return TokenTypes.CLASS_DEF;
066    }
067}