001/*
002 * Copyright 2009-2017 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2017 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds;
022
023
024
025import com.unboundid.util.StaticUtils;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This class provides information about the types of alert severities that may
033 * be included in alert entries.
034 * <BR>
035 * <BLOCKQUOTE>
036 *   <B>NOTE:</B>  This class, and other classes within the
037 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
038 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
039 *   server products.  These classes provide support for proprietary
040 *   functionality or for external specifications that are not considered stable
041 *   or mature enough to be guaranteed to work in an interoperable way with
042 *   other types of LDAP servers.
043 * </BLOCKQUOTE>
044 */
045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
046public enum AlertSeverity
047{
048  /**
049   * The alert severity that indicates that the associated alert is
050   * informational.
051   */
052  INFO("info"),
053
054
055
056  /**
057   * The alert severity that indicates that the associated alert indicates a
058   * warning has occurred.
059   */
060  WARNING("warning"),
061
062
063
064  /**
065   * The alert severity that indicates that the associated alert indicates a
066   * non-fatal error has occurred.
067   */
068  ERROR("error"),
069
070
071
072  /**
073   * The alert severity that indicates that the associated alert indicates a
074   * fatal error has occurred.
075   */
076  FATAL("fatal");
077
078
079
080  // The name for this alert severity.
081  private final String name;
082
083
084
085  /**
086   * Creates a new alert severity with the specified name.
087   *
088   * @param  name  The name for this alert severity.
089   */
090  AlertSeverity(final String name)
091  {
092    this.name = name;
093  }
094
095
096
097  /**
098   * Retrieves the name for this alert severity.
099   *
100   * @return  The name for this alert severity.
101   */
102  public String getName()
103  {
104    return name;
105  }
106
107
108
109  /**
110   * Retrieves the alert severity with the specified name.
111   *
112   * @param  name  The name of the alert severity to retrieve.
113   *
114   * @return  The alert severity with the specified name, or {@code null} if
115   *          there is no alert severity with the given name.
116   */
117  public static AlertSeverity forName(final String name)
118  {
119    final String lowerName = StaticUtils.toLowerCase(name);
120
121    if (lowerName.equals("error"))
122    {
123      return ERROR;
124    }
125    else if (lowerName.equals("fatal"))
126    {
127      return FATAL;
128    }
129    else if (lowerName.equals("info"))
130    {
131      return INFO;
132    }
133    else if (lowerName.equals("warning"))
134    {
135      return WARNING;
136    }
137    else
138    {
139      return null;
140    }
141  }
142
143
144
145  /**
146   * Retrieves a string representation of this alert severity.
147   *
148   * @return  A string representation of this alert severity.
149   */
150  @Override()
151  public String toString()
152  {
153    return name;
154  }
155}