001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2010 Sun Microsystems, Inc. 015 * Portions copyright 2013-2016 ForgeRock AS. 016 */ 017package org.forgerock.opendj.ldap.controls; 018 019/** 020 * A persistent search change type as defined in draft-ietf-ldapext-psearch is 021 * used to indicate the type of update operation that caused an entry change 022 * notification to occur. 023 * 024 * @see PersistentSearchRequestControl 025 * @see EntryChangeNotificationResponseControl 026 * @see <a 027 * href="http://tools.ietf.org/html/draft-ietf-ldapext-psearch">draft-ietf-ldapext-psearch 028 * - Persistent Search: A Simple LDAP Change Notification Mechanism </a> 029 */ 030public enum PersistentSearchChangeType { 031 /** Indicates that an Add operation triggered the entry change notification. */ 032 ADD(1, "add"), 033 /** Indicates that an Delete operation triggered the entry change notification. */ 034 DELETE(2, "delete"), 035 /** Indicates that an Modify operation triggered the entry change notification. */ 036 MODIFY(4, "modify"), 037 /** Indicates that an Modify DN operation triggered the entry change notification. */ 038 MODIFY_DN(8, "modifyDN"); 039 040 private final String name; 041 private final int intValue; 042 043 private PersistentSearchChangeType(final int intValue, final String name) { 044 this.name = name; 045 this.intValue = intValue; 046 } 047 048 @Override 049 public String toString() { 050 return name; 051 } 052 053 /** 054 * Returns the integer value for this change type as defined in the internet 055 * draft. 056 * 057 * @return The integer value for this change type. 058 */ 059 public int intValue() { 060 return intValue; 061 } 062 063 /** 064 * Returns the enum value that would return the provided argument value from its {@link #intValue} method. 065 * 066 * @param value The value to match. 067 * @return The appropriate enum value. 068 */ 069 public static PersistentSearchChangeType valueOf(int value) { 070 switch (value) { 071 case 1: 072 return ADD; 073 case 2: 074 return DELETE; 075 case 4: 076 return MODIFY; 077 case 8: 078 return MODIFY_DN; 079 default: 080 throw new IllegalArgumentException("Unknown int value: " + value); 081 } 082 } 083}