001/*
002 * Copyright 2009-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2009-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2009-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.monitors;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This class provides information about the health check states that may be
050 * held by an LDAP external server.
051 * <BR>
052 * <BLOCKQUOTE>
053 *   <B>NOTE:</B>  This class, and other classes within the
054 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
055 *   supported for use against Ping Identity, UnboundID, and
056 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
057 *   for proprietary functionality or for external specifications that are not
058 *   considered stable or mature enough to be guaranteed to work in an
059 *   interoperable way with other types of LDAP servers.
060 * </BLOCKQUOTE>
061 */
062@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
063public enum HealthCheckState
064{
065  /**
066   * The health check state that indicates that the associated LDAP external
067   * server is available.
068   */
069  AVAILABLE("available"),
070
071
072
073  /**
074   * The health check state that indicates that the associated LDAP external
075   * server is in a degraded state.
076   */
077  DEGRADED("degraded"),
078
079
080
081  /**
082   * The health check state that indicates that the associated LDAP external
083   * server is unavailable.
084   */
085  UNAVAILABLE("unavailable"),
086
087
088
089  /**
090   * The health check state that indicates that there are no local servers
091   * defined, and therefore no health information is available for local
092   * servers.
093   */
094  NO_LOCAL_SERVERS("no-local-servers"),
095
096
097
098  /**
099   * The health check state that indicates that there are no local servers
100   * defined, and therefore no health information is available for remote
101   * servers.
102   */
103  NO_REMOTE_SERVERS("no-remote-servers");
104
105
106
107  // The name for this health check state.
108  @NotNull private final String name;
109
110
111
112  /**
113   * Creates a new health check state with the specified name.
114   *
115   * @param  name  The name for this health check state.
116   */
117  HealthCheckState(@NotNull final String name)
118  {
119    this.name = name;
120  }
121
122
123
124  /**
125   * Retrieves the name for this health check state.
126   *
127   * @return  The name for this health check state.
128   */
129  @NotNull()
130  public String getName()
131  {
132    return name;
133  }
134
135
136
137  /**
138   * Retrieves the health check state with the specified name.
139   *
140   * @param  name  The name of the health check state to retrieve.  It must not
141   *               be {@code null}.
142   *
143   * @return  The health check state with the specified name, or {@code null} if
144   *          there is no health check state with the given name.
145   */
146  @Nullable()
147  public static HealthCheckState forName(@NotNull final String name)
148  {
149    switch (StaticUtils.toLowerCase(name))
150    {
151      case "available":
152        return AVAILABLE;
153      case "degraded":
154        return DEGRADED;
155      case "unavailable":
156        return UNAVAILABLE;
157      case "nolocalservers":
158      case "no-local-servers":
159      case "no_local_servers":
160        return NO_LOCAL_SERVERS;
161      case "noremoteservers":
162      case "no-remote-servers":
163      case "no_remote_servers":
164        return NO_REMOTE_SERVERS;
165      default:
166        return null;
167    }
168  }
169
170
171
172  /**
173   * Retrieves a string representation of this health check state.
174   *
175   * @return  A string representation of this health check state.
176   */
177  @Override()
178  @NotNull()
179  public String toString()
180  {
181    return name;
182  }
183}