001/* 002 * Copyright 2007-2017 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2008-2017 UnboundID Corp. 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.ThreadSafety; 026import com.unboundid.util.ThreadSafetyLevel; 027 028import static com.unboundid.util.StaticUtils.*; 029 030 031 032/** 033 * This enum defines a set of change types that are associated with operations 034 * that may be processed in an LDAP directory server. The defined change types 035 * are "add", "delete", "modify", and "modify DN". 036 */ 037@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 038public enum ChangeType 039{ 040 /** 041 * Indicates that the change type is for an add operation. 042 */ 043 ADD("add"), 044 045 046 047 /** 048 * Indicates that the change type is for a delete operation. 049 */ 050 DELETE("delete"), 051 052 053 054 /** 055 * Indicates that the change type is for a modify operation. 056 */ 057 MODIFY("modify"), 058 059 060 061 /** 062 * Indicates that the change type is for a modify DN operation. 063 */ 064 MODIFY_DN("moddn"); 065 066 067 068 // The human-readable name for this change type. 069 private final String name; 070 071 072 073 /** 074 * Creates a new change type with the specified name. 075 * 076 * @param name The human-readable name for this change type. 077 */ 078 private ChangeType(final String name) 079 { 080 this.name = name; 081 } 082 083 084 085 /** 086 * Retrieves the human-readable name for this change type. 087 * 088 * @return The human-readable name for this change type. 089 */ 090 public String getName() 091 { 092 return name; 093 } 094 095 096 097 /** 098 * Retrieves the change type with the specified name. 099 * 100 * @param name The name of the change type to retrieve. 101 * 102 * @return The requested change type, or {@code null} if no such change type 103 * is defined. 104 */ 105 public static ChangeType forName(final String name) 106 { 107 final String lowerName = toLowerCase(name); 108 if (lowerName.equals("add")) 109 { 110 return ADD; 111 } 112 else if (lowerName.equals("delete")) 113 { 114 return DELETE; 115 } 116 else if (lowerName.equals("modify")) 117 { 118 return MODIFY; 119 } 120 else if (lowerName.equals("moddn") || lowerName.equals("modrdn")) 121 { 122 return MODIFY_DN; 123 } 124 else 125 { 126 return null; 127 } 128 } 129 130 131 132 /** 133 * Retrieves a string representation for this change type. 134 * 135 * @return A string representation for this change type. 136 */ 137 @Override() 138 public String toString() 139 { 140 return name; 141 } 142}