001/*
002 * Copyright 2011-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2011-2019 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;
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 LDAP operation types.
033 */
034@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
035public enum OperationType
036{
037  /**
038   * The operation type that will be used for abandon operations.
039   */
040  ABANDON,
041
042
043
044  /**
045   * The operation type that will be used for add operations.
046   */
047  ADD,
048
049
050
051  /**
052   * The operation type that will be used for bind operations.
053   */
054  BIND,
055
056
057
058  /**
059   * The operation type that will be used for compare operations.
060   */
061  COMPARE,
062
063
064
065  /**
066   * The operation type that will be used for delete operations.
067   */
068  DELETE,
069
070
071
072  /**
073   * The operation type that will be used for extended operations.
074   */
075  EXTENDED,
076
077
078
079  /**
080   * The operation type that will be used for modify operations.
081   */
082  MODIFY,
083
084
085
086  /**
087   * The operation type that will be used for modify DN operations.
088   */
089  MODIFY_DN,
090
091
092
093  /**
094   * The operation type that will be used for search operations.
095   */
096  SEARCH,
097
098
099
100  /**
101   * The operation type that will be used for unbind operations.
102   */
103  UNBIND;
104
105
106
107  /**
108   * Retrieves the operation type with the specified name.
109   *
110   * @param  name  The name of the operation type to retrieve.  It must not be
111   *               {@code null}.
112   *
113   * @return  The requested operation type, or {@code null} if no such operation
114   *          type is defined.
115   */
116  public static OperationType forName(final String name)
117  {
118    switch (StaticUtils.toLowerCase(name))
119    {
120      case "abandon":
121        return ABANDON;
122      case "add":
123        return ADD;
124      case "bind":
125        return BIND;
126      case "compare":
127        return COMPARE;
128      case "delete":
129      case "del":
130        return DELETE;
131      case "extended":
132      case "extendedoperation":
133      case "extended-operation":
134      case "extended_operation":
135      case "extendedop":
136      case "extended-op":
137      case "extended_op":
138      case "extop":
139      case "ext-op":
140      case "ext_op":
141        return EXTENDED;
142      case "modify":
143      case "mod":
144        return MODIFY;
145      case "modifydn":
146      case "modify-dn":
147      case "modify_dn":
148      case "moddn":
149      case "mod-dn":
150      case "mod_dn":
151      case "modifyrdn":
152      case "modify-rdn":
153      case "modify_rdn":
154      case "modrdn":
155      case "mod-rdn":
156      case "mod_rdn":
157        return MODIFY_DN;
158      case "search":
159        return SEARCH;
160      case "unbind":
161        return UNBIND;
162      default:
163        return null;
164    }
165  }
166}