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 * http://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.shared.ldap.extras.controls; 021 022import org.apache.directory.shared.i18n.I18n; 023 024 025/** 026 * 027 * This class describes the four types of states part of the syncStateValue as described in rfc4533. 028 * 029 * state ENUMERATED { 030 * present (0), 031 * add (1), 032 * modify (2), 033 * delete (3), 034 * 035 * #includes the below ApacheDS specific values 036 * moddn(4), 037 * } 038 * 039 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 040 */ 041public enum SyncStateTypeEnum 042{ 043 PRESENT(0), ADD(1), MODIFY(2), DELETE(3), MODDN(4); 044 045 /** the internal value */ 046 private int value; 047 048 049 /** 050 * Private constructor so no other instances can be created other than the 051 * public static constants in this class. 052 * 053 * @param value the integer value of the enumeration. 054 */ 055 private SyncStateTypeEnum( int value ) 056 { 057 this.value = value; 058 } 059 060 061 /** 062 * @return The value associated with the current element. 063 */ 064 public int getValue() 065 { 066 return value; 067 } 068 069 070 /** 071 * Get the {@link SyncStateTypeEnum} instance from an integer value. 072 * 073 * @param value The value we want the enum element from 074 * @return The enum element associated with this integer 075 */ 076 public static SyncStateTypeEnum getSyncStateType( int value ) 077 { 078 if ( value == PRESENT.value ) 079 { 080 return PRESENT; 081 } 082 else if ( value == ADD.value ) 083 { 084 return ADD; 085 } 086 else if ( value == MODIFY.value ) 087 { 088 return MODIFY; 089 } 090 else if ( value == DELETE.value ) 091 { 092 return DELETE; 093 } 094 else if ( value == MODDN.value ) 095 { 096 return MODDN; 097 } 098 099 throw new IllegalArgumentException( I18n.err( I18n.ERR_04163, value ) ); 100 } 101 102}