001/*
002 * Copyright 2009-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 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.monitors;
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 health check states that may be
033 * held by an LDAP external server.
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 HealthCheckState
047{
048  /**
049   * The health check state that indicates that the associated LDAP external
050   * server is available.
051   */
052  AVAILABLE("available"),
053
054
055
056  /**
057   * The health check state that indicates that the associated LDAP external
058   * server is in a degraded state.
059   */
060  DEGRADED("degraded"),
061
062
063
064  /**
065   * The health check state that indicates that the associated LDAP external
066   * server is unavailable.
067   */
068  UNAVAILABLE("unavailable"),
069
070
071
072  /**
073   * The health check state that indicates that there are no local servers
074   * defined, and therefore no health information is available for local
075   * servers.
076   */
077  NO_LOCAL_SERVERS("no-local-servers"),
078
079
080
081  /**
082   * The health check state that indicates that there are no local servers
083   * defined, and therefore no health information is available for remote
084   * servers.
085   */
086  NO_REMOTE_SERVERS("no-remote-servers");
087
088
089
090  // The name for this health check state.
091  private final String name;
092
093
094
095  /**
096   * Creates a new health check state with the specified name.
097   *
098   * @param  name  The name for this health check state.
099   */
100  HealthCheckState(final String name)
101  {
102    this.name = name;
103  }
104
105
106
107  /**
108   * Retrieves the name for this health check state.
109   *
110   * @return  The name for this health check state.
111   */
112  public String getName()
113  {
114    return name;
115  }
116
117
118
119  /**
120   * Retrieves the health check state with the specified name.
121   *
122   * @param  name  The name of the health check state to retrieve.  It must not
123   *               be {@code null}.
124   *
125   * @return  The health check state with the specified name, or {@code null} if
126   *          there is no health check state with the given name.
127   */
128  public static HealthCheckState forName(final String name)
129  {
130    switch (StaticUtils.toLowerCase(name))
131    {
132      case "available":
133        return AVAILABLE;
134      case "degraded":
135        return DEGRADED;
136      case "unavailable":
137        return UNAVAILABLE;
138      case "nolocalservers":
139      case "no-local-servers":
140      case "no_local_servers":
141        return NO_LOCAL_SERVERS;
142      case "noremoteservers":
143      case "no-remote-servers":
144      case "no_remote_servers":
145        return NO_REMOTE_SERVERS;
146      default:
147        return null;
148    }
149  }
150
151
152
153  /**
154   * Retrieves a string representation of this health check state.
155   *
156   * @return  A string representation of this health check state.
157   */
158  @Override()
159  public String toString()
160  {
161    return name;
162  }
163}