001////////////////////////////////////////////////////////////////////////////////
002// checkstyle: Checks Java source code for adherence to a set of rules.
003// Copyright (C) 2001-2017 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.api;
021
022import java.util.Locale;
023
024/**
025 * <p>
026 * Severity level for a check violation.
027 * </p>
028 * <p>
029 * Each violation of an audit check is assigned one of the severity levels
030 * defined here.
031 * </p>
032 *
033 * @author David Schneider
034 * @author Travis Schneeberger
035 * @author Mehmet Can Cömert
036 */
037public enum SeverityLevel {
038    /** Severity level ignore. */
039    IGNORE,
040    /** Severity level info. */
041    INFO,
042    /** Severity level warning. */
043    WARNING,
044    /** Severity level error. */
045    ERROR;
046
047    @Override
048    public String toString() {
049        return getName();
050    }
051
052    /**
053     * Returns name of severity level.
054     * @return the name of this severity level.
055     */
056    public String getName() {
057        return name().toLowerCase(Locale.ENGLISH);
058    }
059
060    /**
061     * SeverityLevel factory method.
062     *
063     * @param securityLevelName level name, such as "ignore", "info", etc.
064     * @return the {@code SeverityLevel}
065     *     associated with {@code securityLevelName}
066     */
067    public static SeverityLevel getInstance(String securityLevelName) {
068        return valueOf(SeverityLevel.class, securityLevelName.trim()
069                .toUpperCase(Locale.ENGLISH));
070    }
071}