001/*
002 * Copyright 2012-2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2012-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) 2015-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.extensions;
037
038
039
040import com.unboundid.util.StaticUtils;
041
042
043
044/**
045 * This enum defines the set of possible values for the element of a
046 * multi-update result which indicates whether any updates were applied to
047 * server data.
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 *
059 * @see MultiUpdateExtendedResult
060 */
061public enum MultiUpdateChangesApplied
062{
063  /**
064   * Indicates that none of the changes contained in the multi-update request
065   * were applied to the server.
066   */
067  NONE(0),
068
069
070
071  /**
072   * Indicates that all of the changes contained in the multi-update request
073   * were applied to the server.
074   */
075  ALL(1),
076
077
078
079  /**
080   * Indicates that one or more changes from the multi-update request were
081   * applied, but at least one failure was also encountered.
082   */
083  PARTIAL(2);
084
085
086
087  // The integer value associated with this changes applied value.
088  private final int intValue;
089
090
091
092  /**
093   * Creates a new multi-update changes applied value with the provided integer
094   * representation.
095   *
096   * @param  intValue  The integer value associated with this changes applied
097   *                   value.
098   */
099  MultiUpdateChangesApplied(final int intValue)
100  {
101    this.intValue = intValue;
102  }
103
104
105
106  /**
107   * Retrieves the integer value associated with this changes applied value.
108   *
109   * @return  The integer value associated with this changes applied value.
110   */
111  public int intValue()
112  {
113    return intValue;
114  }
115
116
117
118  /**
119   * Retrieves the multi-update changes applied value with the specified integer
120   * value.
121   *
122   * @param  intValue  The integer value for the changes applied value to
123   *                   retrieve.
124   *
125   * @return  The multi-update changes applied value with the specified integer
126   *          value, or {@code null} if there is no changes applied value with
127   *          the specified integer value.
128   */
129  public static MultiUpdateChangesApplied valueOf(final int intValue)
130  {
131    for (final MultiUpdateChangesApplied v : values())
132    {
133      if (intValue == v.intValue)
134      {
135        return v;
136      }
137    }
138
139    return null;
140  }
141
142
143
144  /**
145   * Retrieves the multi-update changes applied value with the specified name.
146   *
147   * @param  name  The name of the multi-update changes applied value to
148   *               retrieve.  It must not be {@code null}.
149   *
150   * @return  The requested multi-update changes applied value, or {@code null}
151   *          if no such value is defined.
152   */
153  public static MultiUpdateChangesApplied forName(final String name)
154  {
155    switch (StaticUtils.toLowerCase(name))
156    {
157      case "none":
158        return NONE;
159      case "all":
160        return ALL;
161      case "partial":
162        return PARTIAL;
163      default:
164        return null;
165    }
166  }
167}