001/* 002 * Copyright 2010-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2010-2020 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-2020 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.StaticUtils; 041 042 043 044/** 045 * This enum defines the modes which may be used with the content 046 * synchronization request control. See the documentation for the 047 * {@link ContentSyncRequestControl} class for more information about using the 048 * content synchronization operation. 049 */ 050public enum ContentSyncRequestMode 051{ 052 /** 053 * Indicates that the client only wishes to retrieve information about entries 054 * which have changed up to this point. 055 */ 056 REFRESH_ONLY(1), 057 058 059 060 /** 061 * Indicates that the client wishes to retrieve information about entries 062 * which have changed up to this point, and also to be notified of any 063 * additional matching changes in the future. 064 */ 065 REFRESH_AND_PERSIST(3); 066 067 068 069 // The integer value of this request mode. 070 private final int intValue; 071 072 073 074 /** 075 * Creates a new content synchronization request mode with the specified 076 * integer value. 077 * 078 * @param intValue The integer value for this request mode. 079 */ 080 ContentSyncRequestMode(final int intValue) 081 { 082 this.intValue = intValue; 083 } 084 085 086 087 /** 088 * Retrieves the integer value for this request mode. 089 * 090 * @return The integer value for this request mode. 091 */ 092 public int intValue() 093 { 094 return intValue; 095 } 096 097 098 099 /** 100 * Retrieves the content synchronization request mode with the specified 101 * integer value. 102 * 103 * @param intValue The integer value for which to retrieve the corresponding 104 * request mode. 105 * 106 * @return The content synchronization mode with the specified integer value, 107 * or {@code null} if the given value does not correspond with any 108 * defined mode. 109 */ 110 public static ContentSyncRequestMode valueOf(final int intValue) 111 { 112 if (intValue == REFRESH_ONLY.intValue()) 113 { 114 return REFRESH_ONLY; 115 } 116 else if (intValue == REFRESH_AND_PERSIST.intValue()) 117 { 118 return REFRESH_AND_PERSIST; 119 } 120 else 121 { 122 return null; 123 } 124 } 125 126 127 128 /** 129 * Retrieves the content synchronization request mode with the specified name. 130 * 131 * @param name The name of the content synchronization request mode to 132 * retrieve. It must not be {@code null}. 133 * 134 * @return The requested content sync request mode, or {@code null} if no 135 * such mode is defined. 136 */ 137 public static ContentSyncRequestMode forName(final String name) 138 { 139 switch (StaticUtils.toLowerCase(name)) 140 { 141 case "refreshonly": 142 case "refresh-only": 143 case "refresh_only": 144 return REFRESH_ONLY; 145 case "refreshandpersist": 146 case "refresh-and-persist": 147 case "refresh_and_persist": 148 return REFRESH_AND_PERSIST; 149 default: 150 return null; 151 } 152 } 153}