001/*
002 * Copyright 2012-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2012-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) 2012-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.controls;
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 enum defines the set of operational update types that may be suppressed
050 * by the suppress operational attribute update request control.
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 SuppressType
064{
065  /**
066   * The value that indicates that last access time updates should be
067   * suppressed.
068   */
069  LAST_ACCESS_TIME(0),
070
071
072
073  /**
074   * The value that indicates that last login time updates should be suppressed.
075   */
076  LAST_LOGIN_TIME(1),
077
078
079
080  /**
081   * The value that indicates that last login IP address updates should be
082   * suppressed.
083   */
084  LAST_LOGIN_IP(2),
085
086
087
088  /**
089   * The value that indicates that lastmod updates (creatorsName,
090   * createTimestamp, modifiersName, modifyTimestamp) should be suppressed.
091   */
092  LASTMOD(3);
093
094
095
096  // The integer value for this suppress type enum value.
097  private final int intValue;
098
099
100
101  /**
102   * Creates a new suppress type enum value with the provided information.
103   *
104   * @param  intValue  The integer value for this value, as will be used to
105   *                   indicate it in the request control.
106   */
107  SuppressType(final int intValue)
108  {
109    this.intValue = intValue;
110  }
111
112
113
114  /**
115   * Retrieves the integer value for this suppress type value.
116   *
117   * @return  The integer value for this suppress type value.
118   */
119  public int intValue()
120  {
121    return intValue;
122  }
123
124
125
126  /**
127   * Retrieves the suppress type value for the provided integer value.
128   *
129   * @param  intValue  The integer value for the suppress type value to
130                       retrieve.
131   *
132   * @return  The suppress type value that corresponds to the provided integer
133   *          value, or {@code null} if there is no corresponding suppress type
134   *          value.
135   */
136  @Nullable()
137  public static SuppressType valueOf(final int intValue)
138  {
139    for (final SuppressType t : values())
140    {
141      if (t.intValue == intValue)
142      {
143        return t;
144      }
145    }
146
147    return null;
148  }
149
150
151
152  /**
153   * Retrieves the suppress type with the specified name.
154   *
155   * @param  name  The name of the suppress type to retrieve.  It must not be
156   *               {@code null}.
157   *
158   * @return  The requested suppress type, or {@code null} if no such type is
159   *          defined.
160   */
161  @Nullable()
162  public static SuppressType forName(@NotNull final String name)
163  {
164    switch (StaticUtils.toLowerCase(name))
165    {
166      case "lastaccesstime":
167      case "last-access-time":
168      case "last_access_time":
169        return LAST_ACCESS_TIME;
170      case "lastlogintime":
171      case "last-login-time":
172      case "last_login_time":
173        return LAST_LOGIN_TIME;
174      case "lastloginip":
175      case "last-login-ip":
176      case "last_login_ip":
177        return LAST_LOGIN_IP;
178      case "lastmod":
179        return LASTMOD;
180      default:
181        return null;
182    }
183  }
184}