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 */ 020 package org.apache.directory.shared.ldap.message.control.replication; 021 022 import 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 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 * @version $Rev$, $Date$ 038 */ 039 public enum SyncStateTypeEnum 040 { 041 PRESENT(0), ADD(1), MODIFY(2), DELETE(3); 042 043 /** the internal value */ 044 private int value; 045 046 047 /** 048 * Private constructor so no other instances can be created other than the 049 * public static constants in this class. 050 * 051 * @param value the integer value of the enumeration. 052 */ 053 private SyncStateTypeEnum( int value ) 054 { 055 this.value = value; 056 } 057 058 059 /** 060 * @return The value associated with the current element. 061 */ 062 public int getValue() 063 { 064 return value; 065 } 066 067 068 /** 069 * Get the {@link SyncStateTypeEnum} instance from an integer value. 070 * 071 * @param value The value we want the enum element from 072 * @return The enum element associated with this integer 073 */ 074 public static SyncStateTypeEnum getSyncStateType( int value ) 075 { 076 if ( value == PRESENT.value ) 077 { 078 return PRESENT; 079 } 080 else if ( value == ADD.value ) 081 { 082 return ADD; 083 } 084 else if ( value == MODIFY.value ) 085 { 086 return MODIFY; 087 } 088 else if ( value == DELETE.value ) 089 { 090 return DELETE; 091 } 092 093 throw new IllegalArgumentException( I18n.err( I18n.ERR_04163, value ) ); 094 } 095 096 }