001/* 002 * Copyright 2019-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2019-2020 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) 2019-2020 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.controls; 037 038 039 040import com.unboundid.util.StaticUtils; 041 042 043 044/** 045 * This enum defines a set of values that provide information about the result 046 * of validation processing that the server performed in response to a 047 * {@link UniquenessRequestControl}. 048 * <BR> 049 * <BLOCKQUOTE> 050 * <B>NOTE:</B> This class, and other classes within the 051 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 052 * supported for use against Ping Identity, UnboundID, and 053 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 054 * for proprietary functionality or for external specifications that are not 055 * considered stable or mature enough to be guaranteed to work in an 056 * interoperable way with other types of LDAP servers. 057 * </BLOCKQUOTE> 058 */ 059public enum UniquenessValidationResult 060{ 061 /** 062 * Indicates that the server verified that the requested update did not 063 * conflict with any existing entries at the time the validation processing 064 * was performed. 065 */ 066 VALIDATION_PASSED("validation-passed"), 067 068 069 070 /** 071 * Indicates that the server found at least one other entry in the server that 072 * conflicted with the attempted write operation. 073 */ 074 VALIDATION_FAILED("validation-failed"), 075 076 077 078 /** 079 * Indicates that the server did not attempt any uniqueness validation 080 * processing at the associated point in operation processing. Potential 081 * reasons that no validation may have been attempted include that the 082 * {@link UniquenessRequestControl} indicated that no validation was required 083 * at that point in the processing, because the uniqueness constraint did 084 * not apply to the associated operation (for example, the control indicated 085 * that uniqueness should be maintained for an attribute that was not included 086 * in the update), or that the operation failed for some reason that was not 087 * related to uniqueness processing. 088 */ 089 VALIDATION_NOT_ATTEMPTED("validation-not-attempted"); 090 091 092 093 // The name for this validation result. 094 private final String name; 095 096 097 098 /** 099 * Creates a new uniqueness validation result with the provided name. 100 * 101 * @param name The name for this uniqueness validation result. 102 */ 103 UniquenessValidationResult(final String name) 104 { 105 this.name = name; 106 } 107 108 109 110 /** 111 * Retrieves the name for this uniqueness validation result. 112 * 113 * @return The name for this uniqueness validation result. 114 */ 115 public String getName() 116 { 117 return name; 118 } 119 120 121 122 /** 123 * Retrieves the uniqueness validation result with the given name. 124 * 125 * @param name The name for the uniqueness validation result to retrieve. 126 * It must not be {@code null}. 127 * 128 * @return The uniqueness validation result with the given name, or 129 * {@code null} if there is no result with the given name. 130 */ 131 public static UniquenessValidationResult forName(final String name) 132 { 133 final String n = StaticUtils.toLowerCase(name).replace('_', '-'); 134 for (final UniquenessValidationResult r : values()) 135 { 136 if (r.getName().equals(n)) 137 { 138 return r; 139 } 140 } 141 142 return null; 143 } 144 145 146 147 /** 148 * Retrieves a string representation for this uniqueness validation result. 149 * 150 * @return A string representation for this uniqueness validation result. 151 */ 152 @Override() 153 public String toString() 154 { 155 return name; 156 } 157}