001 /* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2014 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * SonarQube is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020 package org.sonar.api.rules; 021 022 import org.sonar.check.Priority; 023 024 /** 025 * @deprecated since 4.2 026 * @see org.sonar.api.rule.Severity 027 */ 028 @Deprecated 029 public enum RulePriority { 030 031 /** 032 * WARNING : DO NOT CHANGE THE ENUMERATION ORDER 033 * the enum ordinal is used for db persistence 034 */ 035 INFO, MINOR, MAJOR, CRITICAL, BLOCKER; 036 037 private static final String UNKNOWN_PRIORITY = "Unknown priority "; 038 039 /** 040 * A class to map priority level prior to Sonar 1.10 to the new ones 041 * 042 * @param level an old priority level : Error or Warning 043 * @return the corresponding RulePriority 044 * @deprecated in 3.6 045 */ 046 @Deprecated 047 public static RulePriority valueOfString(String level) { 048 try { 049 return RulePriority.valueOf(level.toUpperCase()); 050 051 } catch (IllegalArgumentException ex) { 052 // backward compatibility 053 if ("ERROR".equalsIgnoreCase(level)) { 054 return RulePriority.MAJOR; 055 } else if ("WARNING".equalsIgnoreCase(level)) { 056 return RulePriority.INFO; 057 } 058 } 059 throw new IllegalArgumentException(UNKNOWN_PRIORITY + level); 060 } 061 062 063 public static RulePriority fromCheckPriority(Priority checkPriority) { 064 if (checkPriority == Priority.BLOCKER) { 065 return RulePriority.BLOCKER; 066 } 067 if (checkPriority == Priority.CRITICAL) { 068 return RulePriority.CRITICAL; 069 } 070 if (checkPriority == Priority.MAJOR) { 071 return RulePriority.MAJOR; 072 } 073 if (checkPriority == Priority.MINOR) { 074 return RulePriority.MINOR; 075 } 076 if (checkPriority == Priority.INFO) { 077 return RulePriority.INFO; 078 } 079 throw new IllegalArgumentException(UNKNOWN_PRIORITY + checkPriority); 080 } 081 082 public static RulePriority valueOfInt(int ordinal) { 083 return RulePriority.values()[ordinal]; 084 } 085 }