001/* 002 * Copyright 2010-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2010-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2010-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.controls; 037 038 039 040import com.unboundid.util.NotNull; 041import com.unboundid.util.Nullable; 042import com.unboundid.util.StaticUtils; 043 044 045 046/** 047 * This enum defines the modes which may be used with the content 048 * synchronization request control. See the documentation for the 049 * {@link ContentSyncRequestControl} class for more information about using the 050 * content synchronization operation. 051 */ 052public enum ContentSyncRequestMode 053{ 054 /** 055 * Indicates that the client only wishes to retrieve information about entries 056 * which have changed up to this point. 057 */ 058 REFRESH_ONLY(1), 059 060 061 062 /** 063 * Indicates that the client wishes to retrieve information about entries 064 * which have changed up to this point, and also to be notified of any 065 * additional matching changes in the future. 066 */ 067 REFRESH_AND_PERSIST(3); 068 069 070 071 // The integer value of this request mode. 072 private final int intValue; 073 074 075 076 /** 077 * Creates a new content synchronization request mode with the specified 078 * integer value. 079 * 080 * @param intValue The integer value for this request mode. 081 */ 082 ContentSyncRequestMode(final int intValue) 083 { 084 this.intValue = intValue; 085 } 086 087 088 089 /** 090 * Retrieves the integer value for this request mode. 091 * 092 * @return The integer value for this request mode. 093 */ 094 public int intValue() 095 { 096 return intValue; 097 } 098 099 100 101 /** 102 * Retrieves the content synchronization request mode with the specified 103 * integer value. 104 * 105 * @param intValue The integer value for which to retrieve the corresponding 106 * request mode. 107 * 108 * @return The content synchronization mode with the specified integer value, 109 * or {@code null} if the given value does not correspond with any 110 * defined mode. 111 */ 112 @Nullable() 113 public static ContentSyncRequestMode valueOf(final int intValue) 114 { 115 if (intValue == REFRESH_ONLY.intValue()) 116 { 117 return REFRESH_ONLY; 118 } 119 else if (intValue == REFRESH_AND_PERSIST.intValue()) 120 { 121 return REFRESH_AND_PERSIST; 122 } 123 else 124 { 125 return null; 126 } 127 } 128 129 130 131 /** 132 * Retrieves the content synchronization request mode with the specified name. 133 * 134 * @param name The name of the content synchronization request mode to 135 * retrieve. It must not be {@code null}. 136 * 137 * @return The requested content sync request mode, or {@code null} if no 138 * such mode is defined. 139 */ 140 @Nullable() 141 public static ContentSyncRequestMode forName(@NotNull final String name) 142 { 143 switch (StaticUtils.toLowerCase(name)) 144 { 145 case "refreshonly": 146 case "refresh-only": 147 case "refresh_only": 148 return REFRESH_ONLY; 149 case "refreshandpersist": 150 case "refresh-and-persist": 151 case "refresh_and_persist": 152 return REFRESH_AND_PERSIST; 153 default: 154 return null; 155 } 156 } 157}