001 /* 002 * Copyright 2009-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.monitors; 022 023 024 025 import com.unboundid.util.StaticUtils; 026 import com.unboundid.util.ThreadSafety; 027 import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031 /** 032 * <BLOCKQUOTE> 033 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 034 * LDAP SDK for Java. It is not available for use in applications that 035 * include only the Standard Edition of the LDAP SDK, and is not supported for 036 * use in conjunction with non-UnboundID products. 037 * </BLOCKQUOTE> 038 * This class provides information about the health check states that may be 039 * held by an LDAP external server. 040 */ 041 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 042 public enum HealthCheckState 043 { 044 /** 045 * The health check state that indicates that the associated LDAP external 046 * server is available. 047 */ 048 AVAILABLE("available"), 049 050 051 052 /** 053 * The health check state that indicates that the associated LDAP external 054 * server is in a degraded state. 055 */ 056 DEGRADED("degraded"), 057 058 059 060 /** 061 * The health check state that indicates that the associated LDAP external 062 * server is unavailable. 063 */ 064 UNAVAILABLE("unavailable"), 065 066 067 068 /** 069 * The health check state that indicates that there are no local servers 070 * defined, and therefore no health information is available for local 071 * servers. 072 */ 073 NO_LOCAL_SERVERS("no-local-servers"), 074 075 076 077 /** 078 * The health check state that indicates that there are no local servers 079 * defined, and therefore no health information is available for remote 080 * servers. 081 */ 082 NO_REMOTE_SERVERS("no-remote-servers"); 083 084 085 086 // The name for this health check state. 087 private final String name; 088 089 090 091 /** 092 * Creates a new health check state with the specified name. 093 * 094 * @param name The name for this health check state. 095 */ 096 private HealthCheckState(final String name) 097 { 098 this.name = name; 099 } 100 101 102 103 /** 104 * Retrieves the name for this health check state. 105 * 106 * @return The name for this health check state. 107 */ 108 public String getName() 109 { 110 return name; 111 } 112 113 114 115 /** 116 * Retrieves the health check state with the specified name. 117 * 118 * @param name The name of the health check state to retrieve. 119 * 120 * @return The health check state with the specified name, or {@code null} if 121 * there is no health check state with the given name. 122 */ 123 public static HealthCheckState forName(final String name) 124 { 125 final String lowerName = StaticUtils.toLowerCase(name); 126 127 if (lowerName.equals("available")) 128 { 129 return AVAILABLE; 130 } 131 else if (lowerName.equals("degraded")) 132 { 133 return DEGRADED; 134 } 135 else if (lowerName.equals("unavailable")) 136 { 137 return UNAVAILABLE; 138 } 139 else if (lowerName.equals("no-local-servers") || 140 lowerName.equals("no_local_servers")) 141 { 142 return NO_LOCAL_SERVERS; 143 } 144 else if (lowerName.equals("no-remote-servers") || 145 lowerName.equals("no_remote_servers")) 146 { 147 return NO_REMOTE_SERVERS; 148 } 149 else 150 { 151 return null; 152 } 153 } 154 155 156 157 /** 158 * Retrieves a string representation of this health check state. 159 * 160 * @return A string representation of this health check state. 161 */ 162 @Override() 163 public String toString() 164 { 165 return name; 166 } 167 }