001 /*
002 * Copyright 2010-2014 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2010-2014 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 */
021 package com.unboundid.ldap.sdk.controls;
022
023
024
025 /**
026 * This enum defines the synchronization states for entries returned with the
027 * content synchronization state control. See the documentation for the
028 * {@link ContentSyncRequestControl} class for more information about using the
029 * content synchronization operation.
030 */
031 public enum ContentSyncState
032 {
033 /**
034 * Indicates that the associated entry or reference was already present in
035 * the server when the synchronization was initiated.
036 */
037 PRESENT(0),
038
039
040
041 /**
042 * Indicates that the associated entry or reference was just created by an
043 * add or modify DN operation.
044 */
045 ADD(1),
046
047
048
049 /**
050 * Indicates that the associated entry or reference was just updated by a
051 * modify or modify DN operation.
052 */
053 MODIFY(2),
054
055
056
057 /**
058 * Indicates that the associated entry or reference was just removed by a
059 * delete or modify DN operation.
060 */
061 DELETE(3);
062
063
064
065 // The integer value of this state.
066 private final int intValue;
067
068
069
070 /**
071 * Creates a new content synchronization state with the specified integer
072 * value.
073 *
074 * @param intValue The integer value for this request mode.
075 */
076 private ContentSyncState(final int intValue)
077 {
078 this.intValue = intValue;
079 }
080
081
082
083 /**
084 * Retrieves the integer value for this synchronization state.
085 *
086 * @return The integer value for this synchronization state.
087 */
088 public int intValue()
089 {
090 return intValue;
091 }
092
093
094
095 /**
096 * Retrieves the content synchronization state with the specified integer
097 * value.
098 *
099 * @param intValue The integer value for which to retrieve the corresponding
100 * synchronization state.
101 *
102 * @return The content synchronization state with the specified integer
103 * value, or {@code null} if the given value does not correspond with
104 * any defined state.
105 */
106 public static ContentSyncState valueOf(final int intValue)
107 {
108 if (intValue == PRESENT.intValue())
109 {
110 return PRESENT;
111 }
112 else if (intValue == ADD.intValue())
113 {
114 return ADD;
115 }
116 else if (intValue == MODIFY.intValue())
117 {
118 return MODIFY;
119 }
120 else if (intValue == DELETE.intValue())
121 {
122 return DELETE;
123 }
124 else
125 {
126 return null;
127 }
128 }
129 }