001/*
002 * Copyright 2012-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
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 */
021package com.unboundid.ldap.sdk.unboundidds.controls;
022
023
024
025import com.unboundid.util.StaticUtils;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This enum defines the set of operational update types that may be suppressed
033 * by the suppress operational attribute update request control.
034 * <BR>
035 * <BLOCKQUOTE>
036 *   <B>NOTE:</B>  This class, and other classes within the
037 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
038 *   supported for use against Ping Identity, UnboundID, and
039 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
040 *   for proprietary functionality or for external specifications that are not
041 *   considered stable or mature enough to be guaranteed to work in an
042 *   interoperable way with other types of LDAP servers.
043 * </BLOCKQUOTE>
044 */
045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
046public enum SuppressType
047{
048  /**
049   * The value that indicates that last access time updates should be
050   * suppressed.
051   */
052  LAST_ACCESS_TIME(0),
053
054
055
056  /**
057   * The value that indicates that last login time updates should be suppressed.
058   */
059  LAST_LOGIN_TIME(1),
060
061
062
063  /**
064   * The value that indicates that last login IP address updates should be
065   * suppressed.
066   */
067  LAST_LOGIN_IP(2),
068
069
070
071  /**
072   * The value that indicates that lastmod updates (creatorsName,
073   * createTimestamp, modifiersName, modifyTimestamp) should be suppressed.
074   */
075  LASTMOD(3);
076
077
078
079  // The integer value for this suppress type enum value.
080  private final int intValue;
081
082
083
084  /**
085   * Creates a new suppress type enum value with the provided information.
086   *
087   * @param  intValue  The integer value for this value, as will be used to
088   *                   indicate it in the request control.
089   */
090  SuppressType(final int intValue)
091  {
092    this.intValue = intValue;
093  }
094
095
096
097  /**
098   * Retrieves the integer value for this suppress type value.
099   *
100   * @return  The integer value for this suppress type value.
101   */
102  public int intValue()
103  {
104    return intValue;
105  }
106
107
108
109  /**
110   * Retrieves the suppress type value for the provided integer value.
111   *
112   * @param  intValue  The integer value for the suppress type value to
113                       retrieve.
114   *
115   * @return  The suppress type value that corresponds to the provided integer
116   *          value, or {@code null} if there is no corresponding suppress type
117   *          value.
118   */
119  public static SuppressType valueOf(final int intValue)
120  {
121    for (final SuppressType t : values())
122    {
123      if (t.intValue == intValue)
124      {
125        return t;
126      }
127    }
128
129    return null;
130  }
131
132
133
134  /**
135   * Retrieves the suppress type with the specified name.
136   *
137   * @param  name  The name of the suppress type to retrieve.  It must not be
138   *               {@code null}.
139   *
140   * @return  The requested suppress type, or {@code null} if no such type is
141   *          defined.
142   */
143  public static SuppressType forName(final String name)
144  {
145    switch (StaticUtils.toLowerCase(name))
146    {
147      case "lastaccesstime":
148      case "last-access-time":
149      case "last_access_time":
150        return LAST_ACCESS_TIME;
151      case "lastlogintime":
152      case "last-login-time":
153      case "last_login_time":
154        return LAST_LOGIN_TIME;
155      case "lastloginip":
156      case "last-login-ip":
157      case "last_login_ip":
158        return LAST_LOGIN_IP;
159      case "lastmod":
160        return LASTMOD;
161      default:
162        return null;
163    }
164  }
165}