001/////////////////////////////////////////////////////////////////////////////////////////////// 002// checkstyle: Checks Java source code and other text files for adherence to a set of rules. 003// Copyright (C) 2001-2024 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 */ 034public enum SeverityLevel { 035 036 /** Severity level ignore. */ 037 IGNORE, 038 /** Severity level info. */ 039 INFO, 040 /** Severity level warning. */ 041 WARNING, 042 /** Severity level error. */ 043 ERROR; 044 045 @Override 046 public String toString() { 047 return getName(); 048 } 049 050 /** 051 * Returns name of severity level. 052 * 053 * @return the name of this severity level. 054 */ 055 public String getName() { 056 return name().toLowerCase(Locale.ENGLISH); 057 } 058 059 /** 060 * SeverityLevel factory method. 061 * 062 * @param securityLevelName level name, such as "ignore", "info", etc. 063 * @return the {@code SeverityLevel} 064 * associated with {@code securityLevelName} 065 */ 066 public static SeverityLevel getInstance(String securityLevelName) { 067 return valueOf(SeverityLevel.class, securityLevelName.trim() 068 .toUpperCase(Locale.ENGLISH)); 069 } 070 071}