001/*
002 * Copyright 2009-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2019 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
039 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
040 *   for proprietary functionality or for external specifications that are not
041 *   considered stable or mature enough to be guaranteed to work in an
042 *   interoperable way with 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    switch (StaticUtils.toLowerCase(name))
120    {
121      case "info":
122        return INFO;
123      case "warning":
124        return WARNING;
125      case "error":
126        return ERROR;
127      case "fatal":
128        return FATAL;
129      default:
130        return null;
131    }
132  }
133
134
135
136  /**
137   * Retrieves a string representation of this alert severity.
138   *
139   * @return  A string representation of this alert severity.
140   */
141  @Override()
142  public String toString()
143  {
144    return name;
145  }
146}