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