001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.extras.controls.syncrepl.syncState; 021 022 023import org.apache.directory.api.i18n.I18n; 024 025 026/** 027 * 028 * This class describes the four types of states part of the syncStateValue as described in rfc4533. 029 * 030 * state ENUMERATED { 031 * present (0), 032 * add (1), 033 * modify (2), 034 * delete (3), 035 * 036 * #includes the below ApacheDS specific values 037 * moddn(4), 038 * } 039 * 040 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 041 */ 042public enum SyncStateTypeEnum 043{ 044 /** The entry is present */ 045 PRESENT(0), 046 047 /** The entry has been added */ 048 ADD(1), 049 050 /** The entry has been modified */ 051 MODIFY(2), 052 053 /** The entry has been deleted */ 054 DELETE(3), 055 056 /** The entry has been renamed */ 057 MODDN(4); 058 059 /** the internal value */ 060 private int value; 061 062 063 /** 064 * Private constructor so no other instances can be created other than the 065 * public static constants in this class. 066 * 067 * @param value the integer value of the enumeration. 068 */ 069 SyncStateTypeEnum( int value ) 070 { 071 this.value = value; 072 } 073 074 075 /** 076 * @return The value associated with the current element. 077 */ 078 public int getValue() 079 { 080 return value; 081 } 082 083 084 /** 085 * Get the {@link SyncStateTypeEnum} instance from an integer value. 086 * 087 * @param value The value we want the enum element from 088 * @return The enum element associated with this integer 089 */ 090 public static SyncStateTypeEnum getSyncStateType( int value ) 091 { 092 if ( value == PRESENT.value ) 093 { 094 return PRESENT; 095 } 096 else if ( value == ADD.value ) 097 { 098 return ADD; 099 } 100 else if ( value == MODIFY.value ) 101 { 102 return MODIFY; 103 } 104 else if ( value == DELETE.value ) 105 { 106 return DELETE; 107 } 108 else if ( value == MODDN.value ) 109 { 110 return MODDN; 111 } 112 113 throw new IllegalArgumentException( I18n.err( I18n.ERR_9103_UNKNOWN_SYNC_STATE_TYPE, value ) ); 114 } 115 116}